The python port of libphonenumber is pretty complete, but is a little short on examples and sample code. Here are some simple examples for some common uses of this fantastic library.
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 | |
require("Services/Twilio.php"); | |
$tel_from = "[tel from number]"; // From a Twilio number in your account : CallerID | |
$tel_to = "[tel to number]"; // Call any number | |
$sid = "[set your SID]"; // Your Twilio account sid | |
$token = "[set your AUTH TOKEN]"; // Your Twilio auth token | |
$client = new Services_Twilio($sid, $token); |
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
<?xml version="1.0" encoding="UTF-8"?> | |
<Response> | |
<Say language="ja-jp">Twilioへようこそ。</Say> | |
</Response> |
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 | |
//***ユーザーシリアル、APIキーの設定 | |
$serial = "[ユーザーシリアルID]"; | |
$key = "[APIアクセスキー]"; | |
//**架電情報の設定 | |
$tel_to = "架電先電話番号"; | |
$cast = "file(000001)%%gather(30,2)%%file(000002)"; | |
//**架電用APIにPOST送信を行う(一例) |
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 | |
header("content-type: text/xml"); | |
?> | |
<Response> | |
<?PHP if (empty($_POST["Digits"])): ?> | |
<Say language="ja-jp">Twilioへようこそ。電話の転送は1を、音声ファイルの再生は2を、終了は3を押してください。</Say> | |
<Gather numDigits="1" timeout="30" /> | |
<?PHP elseif ($_POST["Digits"] == "1"): ?> | |
<Dial>[転送先電話番号]</Dial> | |
<Gather numDigits="1" timeout="30" /> |
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
<?xml version="1.0" encoding="UTF-8"?> | |
<Response> | |
<Say language="ja-jp">Twilioへようこそ!</Say> | |
</Response> |
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
import webapp2 | |
from twilio import twiml | |
from twilio.rest import TwilioRestClient | |
class SendSMS(webapp2.RequestHandler): | |
def get(self): | |
# replace with your credentials from: https://www.twilio.com/user/account | |
account_sid = "ACxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" | |
auth_token = "xxxxxxxxxxxxxxxxxxxxxxxxxx" | |
client = TwilioRestClient(account_sid, auth_token) |
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 | |
require '../Services/Twilio.php'; | |
// Connect to MySQL, and connect to the Database | |
mysql_connect('[ServerURL]', '[ID]', '[PWD]') or die(mysql_error()); | |
mysql_select_db('[DB]') or die(mysql_error()); | |
$pollDigits = $_REQUEST['Digits']; | |
$sql_telNo = mysql_query("SELECT * FROM poll"); | |
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 | |
require '../Services/Twilio.php'; | |
$response = new Services_Twilio_Twiml(); | |
$gather = $response->gather(array( | |
'action' => '[your url]/process_poll.php', | |
'method' => 'GET', | |
'timeout' => '30', | |
'numDigits' => '1' | |
)); |
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
curl -X POST 'https://api.twilio.com/2010-04-01/Accounts/your account sid/Calls.xml' \ | |
-d 'From=%2B8150xxxxxxxx' \ | |
-d 'To=%2B8180xxxxxxxx' \ | |
-d 'Url=http%3A%2F%2F<twiML URL>' \ | |
-u <Account SID>:<Auth Token> |
OlderNewer