osms php
1.0.0
php库访问橙色SMS API。
当前版本:2.0.1
安装作曲家。然后,做:
$ composer require ismaeltoe/osms
只需下载最新版本即可。
您可以使用作曲家的自动加载加载课程:
require ' vendor/autoload.php ' ;否则,您只需直接要求文件:
require ' path/to/Osms.php ' ;案例1:您没有访问令牌
require ' vendor/autoload.php ' ;
use Osms Osms ;
$ config = array (
' clientId ' => ' your_client_id ' ,
' clientSecret ' => ' your_client_secret '
);
$ osms = new Osms ( $ config );
// retrieve an access token
$ response = $ osms -> getTokenFromConsumerKey ();
if (! empty ( $ response [ ' access_token ' ])) {
$ senderAddress = ' tel:+22500000000 ' ;
$ receiverAddress = ' tel:+22500000000 ' ;
$ message = ' Hello World! ' ;
$ senderName = ' Optimus Prime ' ;
$ osms -> sendSMS ( $ senderAddress , $ receiverAddress , $ message , $ senderName );
} else {
// error
}案例2:您有访问令牌
require ' vendor/autoload.php ' ;
use Osms Osms ;
$ config = array (
' token ' => ' your_access_token '
);
$ osms = new Osms ( $ config );
$ senderAddress = ' tel:+22500000000 ' ;
$ receiverAddress = ' tel:+22500000000 ' ;
$ message = ' Hello World! ' ;
$ senderName = ' Optimus Prime ' ;
$ osms -> sendSMS ( $ senderAddress , $ receiverAddress , $ message , $ senderName );查看示例以获取更多示例。
还请查看OSMS.PHP以查看所有可用方法。但不要修改它。您可以扩展课程以添加自己的东西。
如果收到SSL错误,请将对等证书检查选项设置为false:
$ osms = new Osms ();
$ osms -> setVerifyPeerSSL ( false );但是它应该在您的托管服务器上工作,因此,出于安全原因,何时准备部署应用程序的证书检查。
根据MIT许可发布 - 有关详细信息,请参见LICENSE.txt 。