2012-07-02 55 views
-2

我使用webaroo api發送消息,我是這個領域的新手,請指導我如何使用此api發送消息。 這裏是API: -使用codeIgniter和php發送消息

<?php 

$method = 'gupshup.getPublicStream';      
$from = '9749633368'; 
$to = '9749633368'; 
$skipadult=true; 


$url = "http://api.smsgupshup.com/GupshupAPI/rest?skipadult=$skipadult&from=$from 
&range=$to&method=$method&v=1.0&format=xml"; 


$ch = curl_init($url); 
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); 
$curl_scraped_page = curl_exec($ch); 
curl_close($ch); 

echo $curl_scraped_page; 
?> 
+0

這不是stackoverflow的工作方式。當你遇到問題/錯誤時,我們在這裏幫助你,而不是編寫教程。請閱讀常見問題解答:http://stackoverflow.com/faq/ – Robert

+0

我使用該代碼發送消息,但它顯示109參數「v」是必需的。請重新發送請求。錯誤「,如何刪除該錯誤,我使用v = 1.0 ..不知道它。 – avinashse

回答

0

笨已經有CURL library

例子:

$this->load->library('curl'); 
echo $this->curl->simple_get('http://api.smsgupshup.com/GupshupAPI/rest?skipadult=$skipadult&from=$from&range=$to&method=$method&v=1.0&format=xml'); 

看到這個:http://codeigniter.com/wiki/Curl_library/

+0

感謝您的答覆,現在它的工作perefctly ,你能告訴我怎樣才能改變發件人ID,現在實際發生的事情是,當我發送消息時,在我的移動設備上它來自TD-2342,而我希望用戶號碼在那裏,這是如何實現的。我正在使用''http://enterprise.smsgupshup.com/GatewayAPI/rest?method=SendMessage&send_to=$to&msg=Welcome%20to%20SMS%20GupShup%20API&msg_type=TEXT&userid=$userid&auth_scheme=plain&password=$password&v=1.1&format=text 「;作爲我的網址 – avinashse

+0

2012年2月1日新的TRAI政策,將只有2類消息 - 交易(銀行警報,鐵路和航空公司警報,來自學校的家長的消息等)和非交易或促銷(所有其他類別)。只有事務性消息纔會有完整的品牌發送者ID(例如TA-HDFCBANK),有更多信息的數字代碼(如TA-n12345或TA-nABCDE)聯繫您的短信服務提供商。 – Sathishkumar

0

我認爲你是在試圖訪問 「HTTP」 網址,只需使用的file_get_contents方法

+0

http://stackoverflow.com/questions/555523/file-get-contents-vs-curl-what-has-better-performance 這就是爲什麼我使用捲曲.. – avinashse