Created
June 14, 2014 07:57
-
-
Save sushat4692/ac7418024c5f709a1777 to your computer and use it in GitHub Desktop.
Twilio API used PHP Libraly
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$to = '09012345678'; // 送信先 | |
// ログイン後のダッシュボードに記載されている情報を入れる | |
$user_id = 'dummy_user_id'; | |
$auth_token = 'dummy_auth_token'; | |
// Twilioで購入した番号を入力 | |
$from = '+18*********'; | |
require_once( 'path/to/Twilio.php' ); | |
$client = new Services_Twilio( $user_id, $auth_token ); | |
try { | |
$client->account->messages->create( array( | |
'To' => preg_replace( '/^0/', '+81', $to ), // 送信先 国際電話になるので、頭の0を+81に変換 | |
'From' => $from, // 送信元 | |
'Body' => $body, // メール本文 | |
) ); | |
} catch( Services_Twilio_RestException $e ) { | |
die( $e->getMessage() ); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment