2015-08-24 4 views
1

Как сделать изображение, найденное в Интернете, и отправить его по MMS в виде изображения.PHP - Отправить изображение через MMS на мобильный телефон через PHP

Я попытался Mail MIME но я получаю эту ошибку:

[23-Aug-2015 19:39:06 America/Detroit] PHP Fatal error: Cannot redeclare class Mail_mimePart in /home/whatevertesting/public_html/test/mimePart.php on line 83

Я в основном смотреть, чтобы увидеть, как этот сайт делает это: http://www.textport.com/send_picture.aspx

Текст изображения на телефон.


Что я пробовал:

Я пошел https://pear.php.net/package/Mail_Mime/ и скачал 1.9.0 stable release. который включал

tests/test_Bug_20xxx.php 
... (test bug goes on for a bit) 
scripts/phail.php 
Mail/mime.php 
Mail/mimePart.php 

Тогда я пошел к примеру https://pear.php.net/manual/en/package.mail.mail-mime.example.php и попробовал то, что было включено, однако ... пример не предоставил mail.php и, таким образом, мой код был:

<?php 

echo "Sending MMS..."; 

error_reporting(E_ALL); 

include 'mime.php'; 
include 'mimePart.php'; 


$text = 'Text version of email'; 
$html = '<html><body>HTML version of email</body></html>'; 
$file = 'hello.txt'; 
$crlf = "\n"; 
$hdrs = array(
       'From' => '[email protected]', 
       'Subject' => 'Test mime message' 
      ); 

$mime = new Mail_mime(array('eol' => $crlf)); 

$mime->setTXTBody($text); 
$mime->setHTMLBody($html); 
$mime->addAttachment($file, 'text/plain'); 

$body = $mime->get(); 
$hdrs = $mime->headers($hdrs); 

$mail =& Mail::factory('mail'); 
$mail->send('[email protected]', $hdrs, $body); 

?> 

Измененная электронная почта ... но вы получите картину. hello.txt также был в том же каталоге, и я переместил mime.php и mimePart.php в ту же директорию, что и код выше.

И ошибка: [23-Aug-2015 19:39:06 America/Detroit] PHP Fatal error: Cannot redeclare class Mail_mimePart in /home/whatevertesting/public_html/test/mimePart.php on line 83 произошло.


Удаление include 'mimePart.php'; дает мне это:

[23-Aug-2015 21:31:18 America/Detroit] PHP Strict Standards: Non-static method Mail_mimePart::encodeHeader() should not be called statically, assuming $this from incompatible context in /home/test_user/public_html/example/mime.php on line 1333 
[23-Aug-2015 21:31:18 America/Detroit] PHP Strict Standards: Non-static method Mail_mimePart::encodeHeader() should not be called statically, assuming $this from incompatible context in /home/test_user/public_html/example/mime.php on line 1333 
[23-Aug-2015 21:31:18 America/Detroit] PHP Strict Standards: Non-static method Mail_mimePart::encodeHeader() should not be called statically, assuming $this from incompatible context in /home/test_user/public_html/example/mime.php on line 1333 
[23-Aug-2015 21:31:18 America/Detroit] PHP Strict Standards: Non-static method Mail_mimePart::_explodeQuotedString() should not be called statically, assuming $this from incompatible context in /usr/local/lib/php/Mail/mimePart.php on line 842 
[23-Aug-2015 21:31:18 America/Detroit] PHP Strict Standards: Non-static method Mail_mimePart::encodeHeader() should not be called statically, assuming $this from incompatible context in /home/test_user/public_html/example/mime.php on line 1333 
[23-Aug-2015 21:31:18 America/Detroit] PHP Fatal error: Class 'Mail' not found in /home/test_user/public_html/example/mms.php on line 27 

ответ

0

Рики от Twilio здесь.

У нас есть API-интерфейс, который позволяет вам send and receive MMS messages. Вот пример кода, как вы бы это с помощью нашего PHP helper library:

<?php 

// this line loads the library 
require('/path/to/twilio-php/Services/Twilio.php'); 

$account_sid = '[AccountSid]'; 
$auth_token = '[AuthToken]'; 
$client = new Services_Twilio($account_sid, $auth_token); 

$client->account->messages->create(array( 
    'To' => "+16518675309", 
    'From' => "+14158141829", 
    'Body' => "Hey Jenny! Good luck on the bar exam!", 
    'MediaUrl' => "http://farm2.static.flickr.com/1075/1404618563_3ed9a44a3a.jpg", 
)); 

Надежда, что помогает!

Смежные вопросы