Soap Client for MMS


Hits: 2105  

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 = “svnlabs.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>’;

?>

Published by

Sandeep Verma

I’m an Entrepreneur. I’m proud to work as Blogger, LAMP Programmer, Linux Admin, Web Consultant, Cloud Manager, Apps Developer, Searcher. Concentrate > Observe > Imagine > Launch