28 June 2019

PHP CURL Script for APIs for Sending Message.... By Using Get And Post Method



<?php
/* Get Method Start */
$arr[] =array("TEXT" =>"hello","MOBLIST" => "8800323585");
$arr[] =array("TEXT" =>"hello","MOBLIST" => "8800323585");
$postData = array(
    "FORMAT" => "2",
    "USERNAME" => "m5demo",
    "PASSWORD" => "m5demo",
    "GSMID" => "SMSSMS",
"TEXTTYPE" => "TEXT",
"SCHNAME" => "",
"SCHDATE" => "",
"SCHHOUR" => "",
"SCHMIN" =>"",
"SMSDATA" => $arr,
);
$myjson= (json_encode($postData));

$domain = "http://smppapim.nimbusmobility.in/api/smpp/JsonAPI?data=".rawurlencode($myjson);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,$domain); 
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
echo $result = curl_exec($ch);
curl_close($ch);
/* Get Method End  */

/* Post Method Start */
$arr[] =array("TEXT" =>"hello","MOBLIST" => "8800323585");
$arr[] =array("TEXT" =>"hello","MOBLIST" => "8800323585");
for($temp=0;$temp<=5;$temp++){
    $arr[] =array("TEXT" =>"hello","MOBLIST" => "8800323585");
}
$postData = array(
    "FORMAT" => "2",
    "USERNAME" => "m5demo",
    "PASSWORD" => "m5demo",
    "GSMID" => "SMSSMS",
"TEXTTYPE" => "TEXT",
"SCHNAME" => "",
"SCHDATE" => "",
"SCHHOUR" => "",
"SCHMIN" =>"",
"SMSDATA" => $arr,
);
$myjson= json_encode($postData);

$domain = "http://smppapim.nimbusmobility.in/api/smpp/JsonPostNew";

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,$domain); 

curl_setopt( $ch, CURLOPT_VERBOSE, true );
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt( $ch, CURLOPT_CUSTOMREQUEST, 'POST' );
curl_setopt($ch, CURLOPT_POSTFIELDS,'data='.urlencode($myjson));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
echo $result = curl_exec($ch);
curl_close($ch);
/* Post Method End */
?>