2012-07-02 58 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