在php url中使用API​​发送短信无响应

时间:2017-04-10 09:45:52

标签: php api post get sms

$data ='username=' .$username . '&api_password=' . $hash . '&sender=' . $sender . "&to=" . $numbers . "&message=" . $message . "&priority=11" ;


// Send the GET request with cURL
$ch = curl_init('http://****************' . $data);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
curl_close($ch);

// Process your response here
echo $response;

我可以使用localhost的这个php代码发送短信。但是,当我将此代码上传到服务器时,我无法从网址获得一个respose。

$data = array('username' => $username, 'api_password' => $hash, "sender" => $sender, 'to' => $numbers, "message" => $message, "priority" => 11);


// Send the POST request with cURL
$ch = curl_init('http://**********************');
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
curl_close($ch);

// Process your response here
echo $response;

我也尝试过这种方法。我可以从我的localhost发送短信。但是当我在我的实时服务器上传这个时没有响应。有没有其他方法在PHP中发送短信?  请帮助!!!

0 个答案:

没有答案