在我的開發環境中,我啓用了CURL。當我通過wamp服務器部署應用程序時,一切正常,我可以在連接到互聯網時發送短信。 現在,當我託管在我的帳戶,它不能發送短信,而它下面顯示短信API在本地服務器上工作,但在託管服務器上不工作
顯示錯誤不可接受 所請求的資源/components/com_spc/smsapi.php的適當代表無法在此找到服務器。 此外,嘗試使用ErrorDocument處理請求時遇到404 Not Found錯誤。 Apache/2.2.26(Unix)mod_ssl/2.2.26 OpenSSL/1.0.1e-fips DAV/2 mod_bwlimited/1.4服務器在www.examplesms.com端口80
以下是工作代碼。
<?php
if(isset($_POST['submit'])){
$data = array(
'username' => $_POST['username'],
'password' => $_POST['password'],
'sender' => $_POST['sender'],
'recipient' => $_POST['recipient'],
'message' => $_POST['message']
);
// Send the POST request with cURL
$ch = curl_init('http://www.examplesms.com/components/com_spc/smsapi.php');
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
curl_setopt ($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
$result = curl_exec($ch); //This is the result from Textlocal
if(curl_exec($ch) === false) {
echo '<font color=red size=4><b>Message sending failed' . '</b></font><br />';
} else {
echo '<font color=orange size=4><b>Message sent successfully' . '</b></font><br />';
echo 'Total number of bytes downloaded: ' . curl_getinfo($ch,CURLINFO_SIZE_DOWNLOAD) . '<br />';
echo 'Total size of all headers received: ' . curl_getinfo($ch,CURLINFO_HEADER_SIZE) . '<br />';
}
curl_close($ch);
//var_dump($result);
print($result);
} else {
?>
<form method="post" style="margin: 5px; padding: 5px;">
<table width="100%" border="0" cellspacing="5px" cellpadding="3px">
<tr>
<td><input name="username" type="hidden" id="username" value="" size="50" style="width: 400px;" /></td>
</tr>
<tr>
<td><input name="password" type="hidden" id="password" value="" size="50" style="width: 400px;" /></td>
</tr>
<tr>
<td><input name="sender" type="hidden" id="sender" size="50" style="width: 400px;" value=""/></td>
</tr>
<tr>
<td>Reciever</td>
<td>
<input name="recipient" type="text" id="recipient" size="50" style="width: 400px;" value=""/>
</td>
</tr>
<tr>
<td>Message</td>
<td><textarea name="message" rows="4" cols="90" id="message" style="width: 400px; height: 120px;"></textarea></td>
</tr>
<tr>
<td>
<td><input type="submit" name="submit" id="add_subcat" value="Send Now!" class="btn btn-info btn-small"></input> <input type="reset" name="Submit2" value="Reset" /></td>
</tr>
</table>
</form>
<?php
}
?>
那是examplesms.com你自己的服務器?或者你的短信提供商的? –
它是我的短信提供商,實際網站是www.nigerianbulksms.com – user3368813