使用php
中的curl方法发送SMS -API使用上述链接我正在调用API,但它无法处理错误为
错误:畸形 在我的代码下方,
//Prepare you post parameters
$postArray = array(
'user' => 'myapi_username',
'password' => 'myapi_password',
'APIKey' => 'my_api_key******',
'number' => 'mobile_number',
'text' => 'sridhar testing',
'senderid' => 'MEDLAB',
'channel' => 'Trans',
'DCS' => '0',
'flashsms' => '0',
'route' => '1'
);
//初始资源
$ch = curl_init();
curl_setopt_array($ch, array(
CURLOPT_URL => $url,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_POST => true,
CURLOPT_POSTFIELDS => http_build_query($postArray)
//,CURLOPT_FOLLOWLOCATION => true
));
//Ignore SSL certificate verification
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
//get response
$curlOutput = curl_exec($ch);
//Print error if any
if (curl_errno($ch)) {
echo 'error:' . curl_error($ch);
}
curl_close($ch);
使用此
$username="*****"; //use your sms api username
$pass = "*******"; //enter your password
$dest_mobileno = "******";//reciever 10 digit number (use comma (,) for multiple users.
$senderid = "*****";//use your sms api sender id
$content = 'TEST%20SMS%20BOSS';
$url2 = "http://login.blesssms.com/api/mt/SendSMS?user=".$username."&password=".$pass."&senderid=".$senderid."&channel=Trans&DCS=0&flashsms=0&number=".$dest_mobileno."&text=".$content."&route=1";
$url = rawurlencode($url);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
$result=curl_exec($ch);
$curlerrno = curl_errno($ch);
curl_close($ch);
print $curlerrno;