请提及如何将下面提到的行改为POST方法发送短信..
// create a new cURL resource
$ch = curl_init();
// set URL and other appropriate options
curl_setopt($ch, CURLOPT_URL, "http://xxxxxxx.com/api/sendmsg.php?user=$user&pass=$pwd&sender=$sender&phone=$pno&text=".urlencode($_REQUEST['MESSAGE'])."&priority=ndnd&stype=normal");
curl_setopt($ch, CURLOPT_HEADER, 0);
// grab URL and pass it to the browser
curl_exec($ch);
// close cURL resource, and free up system resources
curl_close($ch);
答案 0 :(得分:1)
这将有效:
ListView
API返回的响应位于$toPost = array("user" => $user,
"pass" => $pwd,
"sender" => $sender,
"phone" => $pno,
"text" => urlencode($_REQUEST['MESSAGE']),
"priority" => "ndnd",
"stype" => "normal"
);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "http://xxxxxxx.com/api/sendmsg.php");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); // If you use this line, you will get response from API in $result below.
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $toPost);
$result = curl_exec($ch);
curl_close($ch);
变量中。