Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/apache-spark/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
php curl发送http短信发送请求:对象移动错误_Php_Curl - Fatal编程技术网

php curl发送http短信发送请求:对象移动错误

php curl发送http短信发送请求:对象移动错误,php,curl,Php,Curl,我使用php curl发送http请求以发送消息,但它给出了将对象移动到此处的错误 <?php $ch = curl_init(); curl_setopt($ch,CURLOPT_URL, "http://sms.chromeindia.com/SendSms.aspx"); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT

我使用php curl发送http请求以发送消息,但它给出了将对象移动到此处的错误

<?php 
$ch = curl_init();

curl_setopt($ch,CURLOPT_URL,  "http://sms.chromeindia.com/SendSms.aspx");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, "username=XXXXX&password=XXXXXXX&   to=XXXXXXXXXX&from=XXXXXX&message=Get Testing....");
$buffer = curl_exec($ch);
if(empty ($buffer))
{ 
 echo " buffer is empty "; 
}
else // enter code here
{ 
 echo $buffer;
} 
curl_close($ch);

?>

要查看位置,请添加此行:

curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
如果要在postfields中使用空格或@等特殊字符,则需要对其进行URL编码:

curl_setopt($ch, CURLOPT_POSTFIELDS, "username=".urlencode('XXXXX')."&password=".urlencode('XXXXXXX')."&to=".urlencode('XXXXXXXXXX')."&from=".urlencode('XXXXXX')."&message=".urlencode('Get Testing....'));

您尝试访问的URL不存在或已被移动


请先检查您的URL,如果正确,请尝试以下操作:

curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); // changed from 0 to 1

可能重复的

您是否使用了正确的url?