我正在嘗試使用http url調用sms api。我試圖在php.I中使用curl調用url。我得到了一個BAD REQUEST錯誤。請解釋我我做錯了。CURL:嘗試調用http url時發生錯誤請求錯誤
// create a new cURL resource
$ch = curl_init();
$string1 = "http://api.znisms.com/post/smsv3.asp?userid=alpesh67&apikey=74c6314840a16c5e7db00415a03181f7&message= Congratulation you have been successfully registered in the Placement Management System \n Email:".$email."\n Password:".$password."&senderid=PMS12345&sendto=".$contactno."";
echo $string1;
// set URL and other appropriate options
curl_setopt($ch, CURLOPT_URL, $string1);
// grab URL and pass it to the browser
curl_exec($ch);
//close cURL resource, and free up system resources
curl_close($ch);
//SMS END
我得到以下錯誤:
http://api.znisms.com/post/smsv3.asp?userid=alpesh67&apikey=74c6314840a16c5e7db00415a03181f7&message= Congratulation you have been successfully registered in the Placement Management System Email:[email protected] Password:123456789&senderid=PMS12345&sendto=9773396773
Bad Request
我曾嘗試只需撥打從網頁瀏覽器中創建的URL,並將其works.So消息中的空間是沒有問題的。但我仍然嘗試了您的解決方案,但我仍然遇到了錯誤。 – Jonah 2012-03-13 12:43:04
你有更新的錯誤嗎?錯誤中URL的內容應與添加的urlencode()不同。 – Drahkar 2012-03-13 13:01:41
urlencode函數爲我做了訣竅。謝謝 – noobcode 2013-02-03 14:23:41