我正在尝试使用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