2014-03-01 69 views
0

在我的開發環境中,我啓用了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 
} 
?> 
+0

那是examplesms.com你自己的服務器?或者你的短信提供商的? –

+0

它是我的短信提供商,實際網站是www.nigerianbulksms.com – user3368813

回答

0

您將數據直接作爲數組發佈。這意味着它使用多部分表單發佈。

curl_setopt($ch, CURLOPT_POSTFIELDS, $data); 

所以這一個改變:

curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($data)); 
+0

它不起作用。它仍然顯示錯誤 – user3368813

+0

這是錯誤:不可接受 無法在此服務器上找到所請求資源/components/com_spc/smsapi.php的適當表示。 此外,嘗試使用ErrorDocument處理請求時遇到404未找到錯誤。 Apache/2.2.26(Unix)mod_ssl/2.2.26 www.nigerianbulksms.com上的OpenSSL/1.0.1e-fips DAV/2 mod_bwlimited/1.4服務器端口80 – user3368813

相關問題