2013-02-23 21 views
0

工作,我想從我的網站發送短信。 PHP代碼在localhost中工作正常,但沒有從Web服務器獲得任何響應。我錯過了在Web服務器中配置的東西嗎?請幫我.. 這裏是下面給出的代碼...PHP短信代碼是不是從服務器

<?php 

$ch = curl_init("http://priority.muzztech.co.in:8080/sms?"); 
curl_setopt($ch, CURLOPT_POSTFIELDS,"username=username&password=password&type=0&dlr=1&destination=+91xxxxxxxxxx&source=XXXXXX&message=test"); 
curl_setopt($ch, CURLOPT_TIMEOUT,60); 
curl_setopt($ch, CURLOPT_RETURNTRANSFER, True); 

$contents = curl_exec ($ch); 
curl_close ($ch); 

Print($contents); 

/*if(stristr($contents,"Message Submitted")){ 
$mstatus="SMS send Sucessfully ";} 
else { 
$mstatus="SMS send Failed";} 
*/ 

?> 

編輯代碼

<?php 

$ch = curl_init("http://priority.muzztech.co.in:8080/sms?"); 

curl_setopt($ch, CURLOPT_POST, True); 
curl_setopt($ch, CURLOPT_POSTFIELDS,"uusername=username&password=password&type=0&dlr=1&destination=+91xxxxxxxxxx&source=XXXXXX&message=test"); 
curl_setopt($ch, CURLOPT_TIMEOUT,60); 
curl_setopt($ch, CURLOPT_RETURNTRANSFER, True); 

$contents = curl_exec ($ch); 

var_dump(curl_getinfo($ch)); 

curl_close ($ch); 
Print($contents); 
/*if(stristr($contents,"Message Submitted")){ 
$mstatus="SMS send Sucessfully ";} 
else { 
$mstatus="SMS send Failed";} 
*/ 

?> 

頁面顯示

<pre>array(20) { 
["url"]=> string(40) "http://priority.muzztech.co.in:8080/sms?" 
["content_type"]=> NULL 
["http_code"]=> int(0) 
["header_size"]=> int(0) 
["request_size"]=> int(0) 
["filetime"]=> int(-1) 
["ssl_verify_result"]=> int(0) 
["redirect_count"]=> int(0) ["total_time"]=> float(21.226878) 
["namelookup_time"]=> float(0.22723) 
["connect_time"]=> float(0) 
["pretransfer_time"]=> float(0) 
["size_upload"]=> float(0) 
["size_download"]=> float(0) 
["speed_download"]=> float(0) 
["speed_upload"]=> float(0) 
["download_content_length"]=> float(-1) 
["upload_content_length"]=> float(-1) 
["starttransfer_time"]=> float(0) 
["redirect_time"]=> float(0) }</pre> 
+0

好多了! – L0j1k 2013-02-23 11:30:41

+0

的var_dump(curl_getinfo($ CH)); 執行完後但關閉前。 應該給你一些提示。由於此代碼在此處運行,但當然只顯示如下內容:「請求的資源不可用」。 – 2013-02-23 12:09:26

+0

@朱利安希爾謝謝......至少沒有得到一個空白頁......但問題尚未解決。我已經發布了結果與我的問題。 – Subha 2013-02-23 17:22:01

回答

0

當你做捲曲HTTP發佈需要CURLOPT_POSTFIELDS, ...之前指定CURLOPT_POST, true,因爲捲曲的默認HTTP方法是GET。

+0

完成。但仍然有同樣的問題。 – Subha 2013-02-23 11:37:04

0

我也面臨着同樣的問題,並試圖用一整天的時間來解決這個問題。在我的本地主機中一切正常,但是當我把它放在網絡服務器上時,這裏什麼都沒有工作。

我用上面的代碼做了一點改動,現在它正在爲我工​​作。我試圖用很多組合來解決這個問題。令人驚訝的是,當我使用端口號8080時,我看到這裏沒有任何工作。但是,當我刪除端口號並嘗試再次發送我的短信時,它正在工作。我也從上面的代碼中將'uusername'更改爲'username'。

最後我的代碼是:

<?php 

$ch = curl_init("http://priority.muzztech.co.in/sms?"); 

curl_setopt($ch, CURLOPT_POST, True); 
curl_setopt($ch, CURLOPT_POSTFIELDS,"username=username&password=password&type=0&dlr=1&destination=8801XXXXXXXXX&source=XXXXXX&message=test"); 
//8801XXXXXXXXX mobile number format for Bangladesh 
curl_setopt($ch, CURLOPT_TIMEOUT,60); 
curl_setopt($ch, CURLOPT_RETURNTRANSFER, True); 

$contents = curl_exec ($ch); 

curl_close ($ch); 

?> 
此時