在php中如何将发送短信的get方法改为post方法

在php中如何将发送短信的get方法改为post方法,php,curl,Php,Curl,请说明如何将下面提到的行更改为发送短信的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&tex

请说明如何将下面提到的行更改为发送短信的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);
这将有助于:

$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);

API返回的响应位于
$result
变量中。

谢谢Roxinagi先生。。。