Sending MMS from PHP

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
strokesin
Forum Newbie
Posts: 3
Joined: Fri Oct 17, 2008 11:48 pm

Sending MMS from PHP

Post by strokesin »

Hi Friends,

I have to send MMS from our PHP server to MMSC. MMSC will then, forward MMS to the handset. I have got only the Ipaddress & port no. from the MMSC. Like JAVA, i don't find any MMS library available from Nokia to create MMS and send it to MMSC. Find below the source code, i m writing for creating and sending MMS to MMSC.

<?
$msg_header="X-Mms-Message-Type: m-send-req\r\n";
$msg_header.="X-Mms-Transaction-ID: 1000000000\r\n";
$msg_header.="X-Mms-Version: 1.1\r\n";
$msg_header.="X-Mms-Message-ID: strokesin@xyz.com\r\n";
$msg_header.="Date: Fri Oct 17 09:55:52 2008\r\n";
$msg_header.="From: +shortcode/TYPE=PLMN \r\n";
$msg_header.="To: +destination/TYPE=PLMN \r\n";
$msg_header.="Subject: Test MMS message\r\n";
$msg_header.="X-Mms-Message: Information\r\n";
$msg_header.="X-Mms-Priority: Normal\r\n";
$msg_header.="X-Mms-Delivery-Report: Yes\r\n";
$msg_header.="X-Mms-Read-Reply: Yes\r\n";
$msg_header.="X-Mms-Read-Reply: Yes\r\n";
$msg_header.="Content-Type: application/vnd.wap.multipart.related\r\n";



$msg = "<?XML version='1.0' ?>\r\n";
$msg .= "<!DOCTYPE SMIL PUBLIC '-//W3C//DTD SMIL 2.0 Basic//EN'\r\n";
$msg .= "'http://www.w3.org/TR/REC-smil/2000/SMIL ... .dtd'>\r\n";
$msg .= "<smil>\r\n";
$msg .= "<head>\r\n";
$msg .= "<layout>\r\n";
$msg .= "<root-layout width='352' height='144'/>\r\n";
$msg .= "<region id='Image' width='208' height='144' left='0' top='0'/>\r\n";
$msg .= "<region id='Text' width='208' height='144' left='208' top='0'/>\r\n";
$msg .= "</layout>\r\n";
$msg .= "</head>\r\n\r\n";

$msg .= "<body>\r\n";
$msg .= "<par dur='8s'>\r\n";
$msg .= "<img src='pict.gif' region='Image' alt='First image' begin='1s' end='6s'/>\r\n";
$msg .= "<text src='FirstText.txt' region='Text'/>\r\n";
$msg .= "<audio/>\r\n";
$msg .= "</par>\r\n";
$msg .= "</body>\r\n";
$msg .= "</smil>\r\n";

$sendingtobrowser = fsockopen($Ipaddress, $Port, $errno, $errstr, 30);
echo "<br>Connection made....<br>";
if (!$sendingtobrowser)
{
echo "$errstr ($errno)<br />\n";
}

else
{

$out = "POST / HTTP/1.1\r\n";
$out .= "Host: $Ipaddress:$port\r\n";
$out .= $msg_header;
$out .= "Content-Length: " . strlen($msg) . "\r\n\r\n";
$out .= "Connection: Keep-alive\r\n\r\n";
$out .= $msg;

echo "<br>" . $out;

fwrite($sendingtobrowser, $out);
while (!feof($sendingtobrowser)) {
$responsebrowser = $responsebrowser . fgets($sendingtobrowser, 128);
}
fclose($sendingtobrowser);

echo "Response from server......<br>";
echo $responsebrowser;

}
?>

I get the reponse from MMSC as:
HTTP/1.1 400 Message Validation Failed x-nokia-mmsc-version: 4.0 Content-Length: 0
dhirajgmail
Forum Newbie
Posts: 3
Joined: Sat Oct 18, 2008 1:00 am

Re: Sending MMS from PHP

Post by dhirajgmail »

for this u can use the API :)
strokesin
Forum Newbie
Posts: 3
Joined: Fri Oct 17, 2008 11:48 pm

Re: Sending MMS from PHP

Post by strokesin »

Is there any API available for PHP users? Pls let me know.
Post Reply