Skip to content

Instantly share code, notes, and snippets.

View hunnycode's full-sized avatar

joohoun song hunnycode

View GitHub Profile
<?xml version="1.0" encoding="UTF-8"?>
<Response>
<Dial><Queue>queue_01</Queue></Dial>
</Response>
<?php
require_once('../Services/Twilio.php');
$sid = "ACxxxxxxxxxxxxxxx"; // Twilio Account Sid
$token = "yyyyyyyyyyyyyyy"; // Twilio Auth Token
$client = new Services_Twilio($sid, $token);
$call = $client->account->calls->get("CAxxxxxxxxxyyyyyyyyyy"); // Call Sid
$call->update(array(
"Url" => "http://xxx.xxx.xxx.xxx/join_queue.xml",
"Method" => "POST"
<?xml version="1.0" encoding="UTF-8"?>
<Response>
<Enqueue>queue_02</Enqueue>
</Response>
<?php
require_once('../Services/Twilio.php');
$sid = "ACxxxxxxxxxxxxxxx"; // Twilio Account Sid
$token = "yyyyyyyyyyyyyyy"; // Twilio Auth Token
$client = new Services_Twilio($sid, $token);
$call = $client->account->calls->get("CAxxxxxxxxxyyyyyyyyyy"); // Call Sid
$call->update(array(
"Url" => "http://xxx.xxx.xxx.xxx/create_enqueue.xml",
"Method" => "POST"
<?xml version="1.0" encoding="UTF-8"?>
<Response>
<Say language="ja-jp">お電話ありがとうございます。オペレーターとお繋ぎ致します。</Say>
<Dial callerId="+8150xxxxyyyy">+813xxxxyyyy</Dial>
<Enqueue waitUrl="http://xxx.xxx.xxx.xxx/hold_bgm.xml">queue_01</Enqueue>
</Response>
<?xml version="1.0" encoding="UTF-8"?>
<Response>
<Dial callerId="+8150xxxxyyyy" timeout="10">+813xxxxyyyy</Dial>
</Response>
<?xml version="1.0" encoding="UTF-8"?>
<Response>
<Say language="ko-KR">반갑습니다.Twilio는전화를 이용한 최강의 커뮤니케이션 API입니다.</Say>
</Response>
<?php
header("content-type: text/xml");
// 録音ファイルのURLを取得します。
$recording_url = $_POST['RecordingUrl'];
?>
<Response>
<?php if (isset($recording_url)) { ?>
<Say language="ja-jp">録音ファイルを再生いたします。</Say>
<Play><?PHP echo $recording_url; ?></Play>
@hunnycode
hunnycode / curl-change-requesturl.txt
Created October 14, 2014 08:16
curlで電話番号のRequest URL変更
curl -XPOST https://api.twilio.com/2010-04-01/Accounts/[Account Sid]/IncomingPhoneNumbers/[電話番号Sid(PNから始まる34桁)].json \
-d "VoiceUrl=http://[変更するTwiML URL]" \
-u '[Account Sid]:[Auth Token]'
@hunnycode
hunnycode / twiML-ivr-test.php
Created September 30, 2014 09:37
Twilioの人気動詞Gather、電話器のプッシュ音を認識し、いろんな処理を簡単に実現させます。 ref: http://qiita.com/joohounsong/items/e1ca8270eaee395616ed
<?php
require("../Services/Twilio.php");
$response = new Services_Twilio_Twiml();
if (empty($_POST["Digits"])) {
$gather = $response->gather(array('numDigits' => 1, 'timeout' => 30));
$gather->say("許可するには1を拒否は2を押してください。", array('language' => 'ja-jp'));
} elseif ($_POST["Digits"] == "1") {
$response->say("許可を選びました。", array('language' => 'ja-jp'));