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 。