dousong1926 2015-08-05 19:24
浏览 46
已采纳

短信发送网址无法使用curl

I am using below code to send SMS by php curl. From browser when I am running $apiURL it works fine for me. But using below code of curl it's not working. OI gtting O/P as string(0) "". Am I doing something wrong,please help me.

$conturyCode = "91";
$client_mobile = "96******18";
$new_centername = "Apple Hospital";
$address = "Lal Darvaja,ringroad,surat(394220)";
$center_mobile = "86******91";
$apiURL = "http://103.16.101.52:8080/bulksms/bulksms?username=abc-def&password=abc123&type=0&dlr=1&destination=".$conturyCode.$client_mobile."&source=ABC&message=Scheduled at ".$new_centername." and ".$address." and ".$center_mobile;

//  Initiate curl
$ch = curl_init();
//Set User client
curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:27.0) Gecko/20100101 Firefox/27.0");

curl_setopt($ch, CURLOPT_VERBOSE, true);
// Set The Response Format to Json
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json'));
// Set Auto referer
curl_setopt($ch, CURLOPT_AUTOREFERER, true);
// Disable SSL verification
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
// Will return the response, if false it print the response
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
// Set the url
curl_setopt($ch, CURLOPT_URL, $apiURL);
// Execute
$result = curl_exec($ch);

// Check if any error occurred
if(curl_errno($ch))
{
    echo 'Curl error: ' . curl_error($ch);
}

// Closing
curl_close($ch);

var_dump($result);
  • 写回答

2条回答 默认 最新

  • douseda0009 2015-08-06 09:13
    关注

    Try the below code:

    $message = urlencode("Scheduled at ".$new_centername." and ".$address." and ".$center_mobile);
    $apiURL = "http://103.16.101.52:8080/bulksms/bulksms?username=abc-def&password=abc123&type=0&dlr=1&destination=".$conturyCode.$client_mobile."&source=ABC&message=".$message;
    

    The message that you are passing needs to be url encoded.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 关于#Java#的问题,如何解决?
  • ¥15 加热介质是液体,换热器壳侧导热系数和总的导热系数怎么算
  • ¥15 想问一下树莓派接上显示屏后出现如图所示画面,是什么问题导致的
  • ¥100 嵌入式系统基于PIC16F882和热敏电阻的数字温度计
  • ¥15 cmd cl 0x000007b
  • ¥20 BAPI_PR_CHANGE how to add account assignment information for service line
  • ¥500 火焰左右视图、视差(基于双目相机)
  • ¥100 set_link_state
  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化