osms php
1.0.0
オレンジSMS APIにアクセスするPHPライブラリ。
現在のバージョン:2.0.1
作曲家をインストールします。次に、そうします:
$ composer require ismaeltoe/osms
最新リリースをダウンロードするだけです。
Composerのオートロードを使用してクラスをロードできます。
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参照してください。