我正在尝试使用curl执行链接(不重定向页面)。请看下面的代码...
$ch = curl_init(); // Initializing
//curl_setopt($ch, CURLOPT_URL, trim("http://api.smsgatewayhub.com/smsapi/pushsms.aspx?user=stthomasmtc&pwd=429944&to=9176411081&sid=STMTSC&msg=Dear Sam,%20choir%20practice%20will%20be%20held%20in%20our%20Church%20on%20July%2031%20at%208:00%20pm.%20Thanks,%20St.%20Thomas%20MTC!&fl=0&gwid=2")); // Set URI
curl_setopt($ch, CURLOPT_URL,"http://api.smsgatewayhub.com/smsapi/pushsms.aspx?user=stthomasmtc&pwd=429944&to=9176411081&sid=STMTSC&msg=Dear Sam,%20choir%20practice%20will%20be%20held%20in%20our%20Church%20on%20July%2031%20at%208:00%20pm.%20Thanks,%20St.%20Thomas%20MTC!&fl=0&gwid=2"); // Set URI
curl_setopt($ch, CURLOPT_HEADER, 0); //Set Header
curl_setopt($ch, CURLOPT_TIMEOUT, 300); // Time-out in seconds
$result = curl_exec($ch); // Executing
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
if ($httpCode != 200) {
$result = ""; // Executing
}
curl_close($ch); // Closing the channel
return $result;但我得到的响应是Bad Request。
当我尝试将url更改为www.google.com时,它似乎正在执行。当我在浏览器中手动使用此链接时,它会按预期执行-向我发送消息。让我知道如果有一个更好的方式来执行一个链接,而不是页面被重定向…
发布于 2016-04-19 22:19:16
这可能是一个非常古老的问题。但是当你说SMSGatewayHub + SO的时候,它就会在谷歌中弹出,没有人回答,所以我将继续提出一个替代方案。
获取类https://github.com/adarshdec23/SMSGatewayhub。它适用于促销和交易短信。
这里有一个使用它的step by step guide。它使用API密钥而不是您的用户名和密码。一旦你完成了这个任务,这个类就会发出一个API调用(没有cURL)。这很简单,而且可以完成工作。
https://stackoverflow.com/questions/25087560
复制相似问题