昨天和今天,我一直在努力解决这个问题。我可以申请这个论坛没有合适的答案。我以前使用过代码而且工作完美,我不知道我做错了什么。当我在浏览器上输入网址和值时,它可以正常工作,但卷曲功能却没有。当我检查错误时它给了我信息:0但它仍然无效或发布我的价值。
这是我的代码
$contact_phone = $_POST['contact_phone'];
$message = $_POST['message'];
function sendMessage($contact_phone, $message) {
$postValue = "sender=$contact_phone&message=$message&pass=***";
$apiUrl = "http://mydomain.com/components/com_simserver/sim_api.php?";
//next is to fake a browser form submitted
//firefox is our choosing browser
$browserType = "Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.4) Gecko/20030624 Netscape/7.1 (ax)";
/initiating the curl library
$ci = curl_init();
curl_setopt($ci,CURLOPT_FAILONERROR,true);
//set the url to be used for processing the data
curl_setopt($ci, CURLOPT_URL, $apiUrl);
//set our browser type that has been initiad before
curl_setopt($ci, CURLOPT_USERAGENT, $browserType);
//set the maxmium time to execute the script before timing out
curl_setopt($ci, CURLOPT_CONNECTTIMEOUT, 0);
//accept the response after the execution
curl_setopt($ci, CURLOPT_RETURNTRANSFER, true);
// set the post method for passing variables to the server
curl_setopt($ci, CURLOPT_POST, 1);
//assigning the values to be posted to the sms gateway
curl_setopt($ci, CURLOPT_POSTFIELDS, $postValue);
//execute the function and get result from the gateway
$gatewayResult = curl_exec($ci);
echo "Info: " . print_r(curl_error($ci)) . "\n";
curl_close($ci); // close the connection
return $gatewayResult; //returning the gateway feedback
/* return "Message sent"; */
}
$smsGateWay = sendMessage($contact_phone, $message);
if (isset($smsGateWay))
{
echo "message sent"
}
?>
<form method="post">
<input type="text" name="contact_phone" />
<input type="text" name="message" />
<input type="submit" value"submit" />
</form>
答案 0 :(得分:0)
使用:
print_r(curl_errno($ci));
您将获得错误编号,然后参考下面的链接,这可能会有所帮助。
答案 1 :(得分:0)
我已经解决了这个问题。 API / URL不接受发布的值,因此我必须像这样包含CURLOPT_URL上的所有值
$apiUrl = "http://mydomain.com/components/com_simserver/sim_api.php?&sender=$contact_phone&message=$message&pass=***";