如何通过php脚本使用PlaySMS发送短信

时间:2018-02-22 15:13:14

标签: php web server sms kannel

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

的发送短信

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代码来实现这种功能。

1 个答案:

答案 0 :(得分:0)

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

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

2 - ;>为您的PlaySMS帐户启用Web服务并生成Web服务令牌。

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

http://“playSMS服务器在这里”/index.php?app=ws&u=“用户名在这里”& h =“WebServices Token here”& op = pv& to =“Number here”& ; msg =“Msg HERE”

4>>有关PlaySMS webservices URL的更多信息,请访问此处 https://github.com/antonraharja/playSMS/blob/master/documents/development/WEBSERVICES.md

5个;>根据您的需要准备带有适当字段的webservices 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);