Skip to content

Instantly share code, notes, and snippets.

@sushat4692
Created June 14, 2014 07:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sushat4692/ac7418024c5f709a1777 to your computer and use it in GitHub Desktop.
Save sushat4692/ac7418024c5f709a1777 to your computer and use it in GitHub Desktop.
Twilio API used PHP Libraly
<?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