Soap Client for MMS

On October 20, 2009, in Mobiles, PHP, Tips, Web Services, by phpsolutions

Web services are widely supported the major technologies..
There are some ways to make web services: XML-RPC, SOAP and REST

here is the demo in nuSOAP for sending MMS to mobiles using MM7 protocol….

<?
// Pull in the NuSOAP code
require_once(‘nusoap.php’);
require_once(‘nusoapmime.php’);

$wsurl = WEBSERVICEURL;
$operation = “SubmitReq”;
$username = USERNAME;
$password = PASSWORD;
$vaspid = VASPID;
$vasid = VASID;
$shortcode = ShortCode;
$mobileno = NUMBER;  // with country code
$msg = MESSAGE;

$mms = “phpsolutions.gif”;

$TransactionID = time();

$namespace[]= “http://www.3gpp.org/ftp/Specs/archive/23_series/23.140/schema/REL-6-MM7-1-4”;
$ns= “http://www.3gpp.org/ftp/Specs/archive/23_series/23.140/schema/REL-6-MM7-1-4”;
$mm7version = “6.8.0”;

$proxyhost = isset($_POST[‘proxyhost’]) ? $_POST[‘proxyhost’] : ”;
$proxyport = isset($_POST[‘proxyport’]) ? $_POST[‘proxyport’] : ”;
$proxyusername = isset($_POST[‘proxyusername’]) ? $_POST[‘proxyusername’] : ”;
$proxypassword = isset($_POST[‘proxypassword’]) ? $_POST[‘proxypassword’] : ”;
$useCURL = isset($_POST[‘usecurl’]) ? $_POST[‘usecurl’] : ‘0’;

$client = new nusoap_client_mime($wsurl, false,
$proxyhost, $proxyport, $proxyusername, $proxypassword);

// Check for an error
$err = $client->getError();
if ($err) {
// Display the error
echo ‘<p><b>Constructor error: ‘ . $err . ‘</b></p>’;
// At this point, you know the call that follows will fail
}

$client->setCredentials($username, $password);

$client->soap_defencoding = ‘UTF-8’;

$soapaction = “”;

$client->usedNamespaces=$namespace;

$headers = ‘<mm7:TransactionID xmlns:mm7=”‘.$ns.'” mm7:mustUnderstand=”1″>’.$TransactionID.'</mm7:TransactionID>’;

$client->setHeaders($headers);

$params = array(‘MM7Version’=>$mm7version,
‘SenderIdentification’=>array(
‘VASPID’=>$vaspid,’VASID’ =>$vasid,
‘SenderAddress’=>array(‘ShortCode’=>$shortcode)),
‘Recipients’=> array(‘To’=>array(‘Number’=>$mobileno)),
‘DeliveryReport’=>’true’,
‘Subject’=>$msg,
‘Content’=>’mycontentgeneric’);

$client->setUseCurl($useCURL);
$client->setHTTPEncoding(‘deflate, gzip’);
$cid = $client->addAttachment(”, $mms, “image/gif”, “svnMMS”);

$result = $client->call($operation, $params, $ns, $soapaction,$headers);

if ($client->fault) {
echo ‘<h2>Fault</h2><pre>’; print_r($result); echo ‘</pre>’;
} else {
$err = $client->getError();
if ($err) {
echo ‘<h2>Error</h2><pre>’ . $err . ‘</pre>’;
} else {
echo ‘<h2>Result</h2><pre>’; print_r($result); echo ‘</pre>’;
echo ‘<h2>Attachments</h2><pre>’;
$attachments = $client->getAttachments();
foreach ($attachments as $att) {
echo ‘Filename: ‘ . $att[‘filename’] . “\r\n”;
echo ‘Content-Type: ‘ . $att[‘contenttype’] . “\r\n”;
echo ‘cid: ‘ . htmlspecialchars($att[‘cid’], ENT_QUOTES) . “\r\n”;
echo htmlspecialchars($att[‘data’], ENT_QUOTES);
echo “\r\n”;
}
echo ‘</pre>’;
}
}

echo ‘<h2>Request</h2><pre>’ . htmlspecialchars($client->request, ENT_QUOTES) . ‘</pre>’;
echo ‘<h2>Response</h2><pre>’ . htmlspecialchars($client->response, ENT_QUOTES) . ‘</pre>’;

?>

2 Responses to Soap Client for MMS

  1. Anonymous says:

    Intriguing article. I know I’m somewhat late in posting my comment nevertheless the article ended up being the actual and the knowledge I had been in search of. I can’t say i always accept all you could mentioned nevertheless it was emphatically fascinating! BTW…I found your internet site through a Google search. I’m a frequent visitor on your blog and will return again soon.

  2. Anonymous says:

    We are really thankful on the author of this post to create this lovely and informative article live here for us. We really appreciate ur effort. Maintain the good work. . . .

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.