短信网关.ME - 如何使用 PHP API


SMSGATEWAY.ME - How to use the PHP API?

我想使用SMS Gateway PHP API,但我没有成功使用它。我用安卓从SMSGATEWAY下载了该软件。我和我创建了一个帐户。我还有一个免费的网络服务器,我上传了两个文档:

他们的PHP API库"smsGateway.php",人们可以在这里找到:https://smsgateway.me/sms-api-libraries/sms-gateway-me-php.zip

我的文件"测试.php":

<?php
include "smsGateway.php";
$smsGateway = new SmsGateway('my_email_on_their_website', 'my_password_for_this_account');
$deviceID = 111111; //the number of my device, displayed on their website or on the software installed on my phone
$number = '+1234567891'; //the number I want to SMS
$message = 'Hello World!'; //my message
$options = [
    'send_at' => strtotime('+10 minutes'), // Send the message in 10 minutes
    'expires_at' => strtotime('+1 hour') // Cancel the message in 1 hour if the message is not yet sent
];
//Please note options is no required and can be left out
$result = $smsGateway->sendMessageToNumber($number, $message, $deviceID, $options);
?>

但是当我使用浏览器 http://mywwebsite.com/test.php 访问时,它不发送短信,你知道为什么吗?你能帮我解决这个问题吗?(我手机上的网关仍处于活动状态)。

提前谢谢你!

此致敬意

你的代码是正确的。如果要显示结果,请在变量后写$result

echo json_encode($result);

所以你的代码将看起来像这样

    <?php
    include "smsGateway.php";
    $smsGateway = new SmsGateway('my_email_on_their_website', 'my_password_for_this_account');
    $deviceID = 111111; //the number of my device, displayed on their website or on the software installed on my phone
    $number = '+1234567891'; //the number I want to SMS
    $message = 'Hello World!'; //my message
    $options = [
        'send_at' => strtotime('+10 minutes'), // Send the message in 10 minutes
        'expires_at' => strtotime('+1 hour') // Cancel the message in 1 hour if the message is not yet sent
    ];
    //Please note options is no required and can be left out
    $result = $smsGateway->sendMessageToNumber($number, $message, $deviceID, $options);
echo json_encode($result);
    ?>