doute3621 2014-04-16 15:02
浏览 73

使用HTTP SMS API向手机发送消息[重复]

This question already has an answer here:

I've purchased access to an API for a SMS gateway so that I can send messages to mobile phones. They gave me a URL, a username and a password. I want to use this in my PHP program.

My SMS gateway provider gave me the following details:

HTTP Api for single or multiple SMS

http://yourURL/api/smsapi.aspx?username=yourUsername&password=yourPassword&to=9xxxxxxxxx,8xxxxxxxxx,7xxxxxxxxx&from=yourSenderId&message=Your message content.
  • username: Your login username.
  • password: Your login password.
  • to: Single mobile number or multiple mobile numbers separated by comma (Only 10 digits).
  • from: Approved sender id (Only 6 characters).
  • message: Your message content (Maximum 459 characters/3 messages).
    • Note: Only 100 mobile numbers are allowed.

I tried many ways to use this, but I couldn't find a solution. How would I implement this in my PHP program?

</div>
  • 写回答

1条回答 默认 最新

  • dousong4777 2014-04-16 15:21
    关注

    use CURL to call api.CURL is better way to call api.

    <?php
    $url = 'http://yourURL/api/smsapi.aspx?username=yourUsername&password=yourPassword&to=9xxxxxxxxx,8xxxxxxxxx,7xxxxxxxxx&from=yourSenderId&message=Your message content.';
    
    $ch = curl_init(); 
    curl_setopt($ch,CURLOPT_URL,$url);
    curl_setopt($ch,CURLOPT_RETURNTRANSFER,true);
    $output=curl_exec($ch);
    if(curl_errno($ch))
    {
        echo 'error:' . curl_error($c);
    }
    curl_close($ch);
    
    ?>
    
    评论

报告相同问题?

悬赏问题

  • ¥15 k8s部署jupyterlab,jupyterlab保存不了文件
  • ¥15 ubuntu虚拟机打包apk错误
  • ¥199 rust编程架构设计的方案 有偿
  • ¥15 回答4f系统的像差计算
  • ¥15 java如何提取出pdf里的文字?
  • ¥100 求三轴之间相互配合画圆以及直线的算法
  • ¥100 c语言,请帮蒟蒻写一个题的范例作参考
  • ¥15 名为“Product”的列已属于此 DataTable
  • ¥15 安卓adb backup备份应用数据失败
  • ¥15 eclipse运行项目时遇到的问题