【问题标题】:How to send sms using PlaySMS through a php script如何通过 php 脚本使用 PlaySMS 发送短信
【发布时间】:2018-02-22 15:13:14
【问题描述】:

我正在尝试使用 PHP 脚本发送短信。短信网关是 Kannel,在此基础上,他们使用 PlaySMS 基于 Web 的移动门户系统进行管理。我知道如何通过使用 cURL 直接与 Kannel HTTP sendms 接口通信来发送短信,以执行类似

(http://127.0.0.1:10200/cgi-bin/sendsms?user=myuser&pass=xyz&text=Hello&to=123456789&from=test)

但是我想使用 PlaySMS 而不是直接与 Kannel 网关通信。是否有某种 PlaySMS HTTP 接口用于发送与 Kannel 相同的短信?我想使用 PHP 代码来实现此功能。

【问题讨论】:

    标签: php web server sms kannel


    【解决方案1】:

    我已找到问题的答案。应遵循以下步骤

    1>> 确保您拥有 SMS 网关服务提供商提供的 PlaySMS 用户帐户。

    2>> 为您的 PlaySMS 帐户启用网络服务并生成网络服务令牌。

    3>>现在需要向托管PlaySMS的服务器发送http POST或GET请求。基本请求URL格式如下。

    http://"playSMS server here"/index.php?app=ws&u="user name here"&h="WebServices Token here"&op=pv&to="Number here"&msg="Msg HERE"

    4>> 更多关于 PlaySMS 网络服务 URL 的信息可以在这里找到 https://github.com/antonraharja/playSMS/blob/master/documents/development/WEBSERVICES.md

    5>>根据您的需要准备好带有适当字段的 web 服务 URL 后,您现在只需将请求发送到 PlaySMS 服务器。

    6>> 使用 curl() 或 file_get_contents() 发送请求,使用 curl 发送 GET 请求的过程如下:

    $url = "http://fakeplaySMSserver.com/index.php?
    app=ws&u=Test&h=bfcblablabla&op=pv&to=0335632121&msg=Hello!;
    
    $ch = curl_init($url); // modify the webservices url as per your needs 
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    $data = curl_exec($ch);
    curl_close($ch);
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多