├── .gitignore ├── LICENSE ├── README.md ├── app.json ├── auth.php ├── composer.json ├── composer.lock ├── ss1.png ├── start.sh ├── twiml.php └── vendor ├── autoload.php ├── composer ├── ClassLoader.php ├── autoload_classmap.php ├── autoload_namespaces.php ├── autoload_psr4.php ├── autoload_real.php └── installed.json └── twilio └── sdk ├── .gitignore ├── .travis.yml ├── AUTHORS.md ├── CHANGES.md ├── LICENSE ├── Makefile ├── README.md ├── Services ├── Twilio.php ├── Twilio │ ├── AutoPagingIterator.php │ ├── Capability.php │ ├── HttpException.php │ ├── HttpStream.php │ ├── InstanceResource.php │ ├── ListResource.php │ ├── NumberType.php │ ├── Page.php │ ├── PartialApplicationHelper.php │ ├── RequestValidator.php │ ├── Resource.php │ ├── Rest │ │ ├── Account.php │ │ ├── Accounts.php │ │ ├── Application.php │ │ ├── Applications.php │ │ ├── AuthorizedConnectApp.php │ │ ├── AuthorizedConnectApps.php │ │ ├── AvailablePhoneNumber.php │ │ ├── AvailablePhoneNumbers.php │ │ ├── Call.php │ │ ├── Calls.php │ │ ├── Conference.php │ │ ├── Conferences.php │ │ ├── ConnectApp.php │ │ ├── ConnectApps.php │ │ ├── Credential.php │ │ ├── CredentialList.php │ │ ├── CredentialListMapping.php │ │ ├── CredentialListMappings.php │ │ ├── CredentialLists.php │ │ ├── Credentials.php │ │ ├── Domain.php │ │ ├── Domains.php │ │ ├── IncomingPhoneNumber.php │ │ ├── IncomingPhoneNumbers.php │ │ ├── IpAccessControlList.php │ │ ├── IpAccessControlListMapping.php │ │ ├── IpAccessControlListMappings.php │ │ ├── IpAccessControlLists.php │ │ ├── IpAddress.php │ │ ├── IpAddresses.php │ │ ├── Media.php │ │ ├── MediaInstance.php │ │ ├── Member.php │ │ ├── Members.php │ │ ├── Message.php │ │ ├── Messages.php │ │ ├── Notification.php │ │ ├── Notifications.php │ │ ├── OutgoingCallerId.php │ │ ├── OutgoingCallerIds.php │ │ ├── Participant.php │ │ ├── Participants.php │ │ ├── Queue.php │ │ ├── Queues.php │ │ ├── Recording.php │ │ ├── Recordings.php │ │ ├── Sandbox.php │ │ ├── ShortCode.php │ │ ├── ShortCodes.php │ │ ├── Sip.php │ │ ├── SmsMessage.php │ │ ├── SmsMessages.php │ │ ├── Transcription.php │ │ ├── Transcriptions.php │ │ ├── UsageRecord.php │ │ ├── UsageRecords.php │ │ ├── UsageTrigger.php │ │ └── UsageTriggers.php │ ├── RestException.php │ ├── SIPListResource.php │ ├── TimeRangeResource.php │ ├── TinyHttp.php │ ├── Twiml.php │ └── UsageResource.php └── cacert.pem ├── composer.json ├── composer.lock ├── docs ├── Makefile ├── _themes │ ├── .gitignore │ ├── LICENSE │ ├── README.rst │ ├── flask_theme_support.py │ ├── kr │ │ ├── layout.html │ │ ├── relations.html │ │ ├── static │ │ │ ├── flasky.css_t │ │ │ └── small_flask.css │ │ └── theme.conf │ └── kr_small │ │ ├── layout.html │ │ ├── static │ │ └── flasky.css_t │ │ └── theme.conf ├── api │ ├── rest.rst │ ├── services.rst │ └── twiml.rst ├── conf.py ├── faq.rst ├── index.rst ├── quickstart.rst ├── requirements.txt └── usage │ ├── rest.rst │ ├── rest │ ├── accounts.rst │ ├── applications.rst │ ├── callerids.rst │ ├── calls.rst │ ├── conferences.rst │ ├── members.rst │ ├── messages.rst │ ├── notifications.rst │ ├── phonenumbers.rst │ ├── queues.rst │ ├── recordings.rst │ ├── sip.rst │ ├── sms-messages.rst │ ├── transcriptions.rst │ ├── usage-records.rst │ └── usage-triggers.rst │ ├── token-generation.rst │ ├── twiml.rst │ └── validation.rst ├── package.php └── tests ├── Bootstrap.php ├── BuildQueryTest.php ├── CapabilityTest.php ├── README ├── RequestValidatorTest.php ├── TwilioTest.php ├── TwimlTest.php ├── phpunit.xml └── resources ├── AccountsTest.php ├── ApplicationsTest.php ├── AvailablePhoneNumbersTest.php ├── CallsTest.php ├── ConnectAppsTest.php ├── IncomingPhoneNumbersTest.php ├── MediaTest.php ├── MembersTest.php ├── MessagesTest.php ├── NotificationTest.php ├── OutgoingCallerIdsTest.php ├── QueuesTest.php ├── SMSMessagesTest.php ├── SandboxTest.php ├── ShortCodesTest.php ├── UsageRecordsTest.php └── UsageTriggersTest.php /.gitignore: -------------------------------------------------------------------------------- 1 | secrets.txt 2 | clients.txt 3 | composer.phar 4 | .DS_Store 5 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2014 Joseph Constantakis 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | Twilio Client Server 2 | =================== 3 | 4 | Get all the necessary server-side junk for Twilio Client set up quickly and easily using this simple php server. 5 | 6 | 7 | Prerequisites 8 | ------------- 9 | Make sure you have [created a Twilio account](https://www.twilio.com/try-twilio) and [a TwiML application](https://www.twilio.com/user/account/apps/). You will need your Twilio Account SID & token, as well as your app SID, to deploy this server. After deploying your server, be sure to point your TwiML app's "Voice Request URL" back to twiml.php on your server, like so: 10 | 11 | 12 | 13 | Usage 14 | ----- 15 | To deploy using [Heroku](https://heroku.com/), just click here: 16 | 17 | [![Deploy](https://www.herokucdn.com/deploy/button.png)](https://heroku.com/deploy) 18 | 19 | Or, if you prefer, you can also test using [ngrok](https://ngrok.com/). Just create an ngrok account & install it, then clone this repo and run `./start.sh any-subdomain-you-want`. The script will take you through the process. 20 | 21 | PhoneKit for iOS 22 | ---------------- 23 | 24 | If you're using this server wih an iOS app, check out [PhoneKit](https://github.com/jconst/PhoneKit). It is made specifically to interact with this library to provide useful features that address the most common use cases for the Twilio iOS SDK. 25 | 26 | ####WARNING#### 27 | Twilio Client Server is just a template aimed at mobile developers who want to get started using Twilio Client without having to worry about setting up a server *right away*. If you put this code (unchanged) on your production server, someone **will** end up using your tokens in their own apps for free Twilio calls, charged to your account. In production, you should always ensure that your capability token server is securely protected. 28 | -------------------------------------------------------------------------------- /app.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "Twilio Client Server", 3 | "description": "A simple php server to distribute capability tokens and route calls for your mobile app", 4 | "repository": "https://github.com/jconst/twilio-client-server", 5 | "logo": "https://www.twilio.com/packages/company/img/logos_downloadable_logobrand.png", 6 | "keywords": [ 7 | "twilio", 8 | "client", 9 | "mobile" 10 | ], 11 | "env": { 12 | "TWILIO_ACCOUNT_SID": { 13 | "description": "Your Twilio account id", 14 | "required": true 15 | }, 16 | "TWILIO_AUTH_TOKEN": { 17 | "description": "Your Twilio authentication token", 18 | "required": true 19 | }, 20 | "TWILIO_APP_SID": { 21 | "description": "The app sid for the TwiML app (in Account->Dev Tools->TwiML Apps) that points to this server", 22 | "required": true 23 | } 24 | } 25 | } -------------------------------------------------------------------------------- /auth.php: -------------------------------------------------------------------------------- 1 | allowClientIncoming($clientName); 26 | 27 | // This allows outgoing connections to $appSid with the 'From' 28 | // parameter being the value of $clientName 29 | $capability->allowClientOutgoing($appSid, array(), $clientName); 30 | 31 | // This returns a token to use with Twilio based on 32 | // the account and capabilities defined above 33 | $token = $capability->generateToken(); 34 | 35 | echo json_encode(array('token'=>$token, 'clients'=>$clients)); 36 | ?> 37 | -------------------------------------------------------------------------------- /composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "require": { 3 | "twilio/sdk": "3.*" 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /composer.lock: -------------------------------------------------------------------------------- 1 | { 2 | "_readme": [ 3 | "This file locks the dependencies of your project to a known state", 4 | "Read more about it at http://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", 5 | "This file is @generated automatically" 6 | ], 7 | "hash": "1ba5285d4ad9b62cabe46d387bfb690b", 8 | "packages": [ 9 | { 10 | "name": "twilio/sdk", 11 | "version": "3.12.5", 12 | "source": { 13 | "type": "git", 14 | "url": "https://github.com/twilio/twilio-php.git", 15 | "reference": "be6b2eec33ec665827cfd780f98f732a6e0e84eb" 16 | }, 17 | "dist": { 18 | "type": "zip", 19 | "url": "https://api.github.com/repos/twilio/twilio-php/zipball/be6b2eec33ec665827cfd780f98f732a6e0e84eb", 20 | "reference": "be6b2eec33ec665827cfd780f98f732a6e0e84eb", 21 | "shasum": "" 22 | }, 23 | "require": { 24 | "php": ">=5.2.1" 25 | }, 26 | "require-dev": { 27 | "mockery/mockery": ">=0.7.2", 28 | "phpunit/phpunit": "3.7.*" 29 | }, 30 | "type": "library", 31 | "autoload": { 32 | "psr-0": { 33 | "Services_Twilio": "" 34 | } 35 | }, 36 | "notification-url": "https://packagist.org/downloads/", 37 | "license": [ 38 | "MIT" 39 | ], 40 | "authors": [ 41 | { 42 | "name": "Kevin Burke", 43 | "email": "kevin@twilio.com" 44 | }, 45 | { 46 | "name": "Kyle Conroy", 47 | "email": "kyle+pear@twilio.com" 48 | } 49 | ], 50 | "description": "A PHP wrapper for Twilio's API", 51 | "homepage": "http://github.com/twilio/twilio-php", 52 | "keywords": [ 53 | "api", 54 | "sms", 55 | "twilio" 56 | ], 57 | "time": "2014-07-15 17:12:48" 58 | } 59 | ], 60 | "packages-dev": [ 61 | 62 | ], 63 | "aliases": [ 64 | 65 | ], 66 | "minimum-stability": "stable", 67 | "stability-flags": [ 68 | 69 | ], 70 | "prefer-stable": false, 71 | "platform": [ 72 | 73 | ], 74 | "platform-dev": [ 75 | 76 | ] 77 | } 78 | -------------------------------------------------------------------------------- /ss1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jconst/twilio-client-server/d760dbc26a849fde9f96d73bb33a96065394bbf9/ss1.png -------------------------------------------------------------------------------- /start.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | endpoint="auth.php" 4 | port_num=$([ $# -eq 2 ] && echo "$2" || echo "5000") 5 | 6 | function main() { 7 | check_tools 8 | check_args $1 9 | trap 'exit' ERR 10 | export_credentials 11 | start_server & 12 | start_ngrok 13 | } 14 | 15 | function check_tools() { 16 | if ! type ngrok &>/dev/null; then 17 | echo "Please install ngrok and create an account before running this script" 18 | echo "$(tput setaf 4)http://ngrok.com$(tput sgr0)" 19 | exit 1 20 | fi 21 | } 22 | 23 | function check_args() { 24 | if [ $# -lt 1 ] || [ $# -gt 2 ] || [ $1 == "--help" ] || [ $1 == "-h" ] 25 | then 26 | echo "please specify your preferred ngrok subdomain name, like so:" 27 | echo "./this-script.sh mysubdomain [port]" 28 | exit 1 29 | fi 30 | subdomain=$1 31 | } 32 | 33 | function export_credentials() { 34 | if [ -z $TWILIO_ACCOUNT_SID ] || [ -z $TWILIO_AUTH_TOKEN ] || [ -z $TWILIO_APP_SID ]; then 35 | echo "What is your twilio account sid?" 36 | read account_sid 37 | 38 | echo "What is your auth token?" 39 | read auth_token 40 | 41 | echo "What is your TwiML app sid?" 42 | read app_sid 43 | 44 | export TWILIO_ACCOUNT_SID=$account_sid 45 | export TWILIO_AUTH_TOKEN=$auth_token 46 | export TWILIO_APP_SID=$app_sid 47 | fi 48 | } 49 | 50 | function start_server() { 51 | echo "starting php server on http://127.0.0.1:$port_num" 52 | echo "$(tput setaf 2)GET http://127.0.0.1:$port_num/$endpoint$(tput sgr0) to fetch a capability token for your iOS/Android app" 53 | php -S 127.0.0.1:$port_num 54 | } 55 | 56 | function start_ngrok() { 57 | ngrok -subdomain=$subdomain $port_num 58 | } 59 | 60 | main $@ 61 | -------------------------------------------------------------------------------- /twiml.php: -------------------------------------------------------------------------------- 1 | 11 | if (isset($digits) && !$callee) { 12 | $callee = $_REQUEST[$digits]; 13 | } 14 | 15 | $response = new Services_Twilio_Twiml(); 16 | 17 | if ($callee) { 18 | $response->dial($callee, array('callerId'=>$callerId)); 19 | } else if (preg_match("/^[\d\(\)\-\+ ]+$/", $from)) { 20 | $contents = @file_get_contents('clients.txt'); 21 | $lines = array_slice(array_filter(explode(',', $contents)), 0, 10); 22 | if (!$contents) { 23 | $response->dial('default', array('callerId'=>$callerId)); 24 | } else if (count($lines) == 1) { 25 | $response->dial($lines[0], array('callerId'=>$callerId)); 26 | } else { 27 | # Since we don't know (from the Request params) whom a 28 | # regular PSTN phone wants to call, let them choose 29 | $options = $lines; 30 | array_walk($options, function(&$elt, $idx){ $elt = "$idx to call $elt"; }); 31 | $say = 'Press ' . implode(', ', $options) . '.'; 32 | $here = pathinfo(__FILE__, PATHINFO_BASENAME); 33 | $gather = $response->gather(array('action'=>"/{$here}?".http_build_query($lines), 34 | 'numDigits'=>'1')); 35 | $gather->say($say, array('voice'=>'woman')); 36 | } 37 | } else { 38 | $response->say('Congratulations! You just made a call using Twilio Client! That is awesome!', 39 | array('voice'=>'woman')); 40 | } 41 | print $response; 42 | ?> 43 | -------------------------------------------------------------------------------- /vendor/autoload.php: -------------------------------------------------------------------------------- 1 | array($vendorDir . '/twilio/sdk'), 10 | ); 11 | -------------------------------------------------------------------------------- /vendor/composer/autoload_psr4.php: -------------------------------------------------------------------------------- 1 | $path) { 28 | $loader->set($namespace, $path); 29 | } 30 | 31 | $map = require __DIR__ . '/autoload_psr4.php'; 32 | foreach ($map as $namespace => $path) { 33 | $loader->setPsr4($namespace, $path); 34 | } 35 | 36 | $classMap = require __DIR__ . '/autoload_classmap.php'; 37 | if ($classMap) { 38 | $loader->addClassMap($classMap); 39 | } 40 | 41 | $loader->register(true); 42 | 43 | return $loader; 44 | } 45 | } 46 | 47 | function composerRequire558a7898e7727ef1f15de58b1f4cb518($file) 48 | { 49 | require $file; 50 | } 51 | -------------------------------------------------------------------------------- /vendor/composer/installed.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "name": "twilio/sdk", 4 | "version": "3.12.5", 5 | "version_normalized": "3.12.5.0", 6 | "source": { 7 | "type": "git", 8 | "url": "https://github.com/twilio/twilio-php.git", 9 | "reference": "be6b2eec33ec665827cfd780f98f732a6e0e84eb" 10 | }, 11 | "dist": { 12 | "type": "zip", 13 | "url": "https://api.github.com/repos/twilio/twilio-php/zipball/be6b2eec33ec665827cfd780f98f732a6e0e84eb", 14 | "reference": "be6b2eec33ec665827cfd780f98f732a6e0e84eb", 15 | "shasum": "" 16 | }, 17 | "require": { 18 | "php": ">=5.2.1" 19 | }, 20 | "require-dev": { 21 | "mockery/mockery": ">=0.7.2", 22 | "phpunit/phpunit": "3.7.*" 23 | }, 24 | "time": "2014-07-15 17:12:48", 25 | "type": "library", 26 | "installation-source": "dist", 27 | "autoload": { 28 | "psr-0": { 29 | "Services_Twilio": "" 30 | } 31 | }, 32 | "notification-url": "https://packagist.org/downloads/", 33 | "license": [ 34 | "MIT" 35 | ], 36 | "authors": [ 37 | { 38 | "name": "Kevin Burke", 39 | "email": "kevin@twilio.com" 40 | }, 41 | { 42 | "name": "Kyle Conroy", 43 | "email": "kyle+pear@twilio.com" 44 | } 45 | ], 46 | "description": "A PHP wrapper for Twilio's API", 47 | "homepage": "http://github.com/twilio/twilio-php", 48 | "keywords": [ 49 | "api", 50 | "sms", 51 | "twilio" 52 | ] 53 | } 54 | ] 55 | -------------------------------------------------------------------------------- /vendor/twilio/sdk/.gitignore: -------------------------------------------------------------------------------- 1 | docs/_build/ 2 | vendor/* 3 | composer.phar 4 | coverage 5 | package.xml 6 | *.tgz 7 | 8 | # You should be keeping these in a global gitignore, see for example 9 | # https://help.github.com/articles/ignoring-files#global-gitignore 10 | .DS_Store 11 | .idea 12 | 13 | nbproject 14 | 15 | # This is used by the documentation generator 16 | venv 17 | -------------------------------------------------------------------------------- /vendor/twilio/sdk/.travis.yml: -------------------------------------------------------------------------------- 1 | language: php 2 | php: 3 | - 5.3 4 | - 5.4 5 | - 5.5 6 | script: "make test" 7 | before_install: "composer install --dev" 8 | -------------------------------------------------------------------------------- /vendor/twilio/sdk/AUTHORS.md: -------------------------------------------------------------------------------- 1 | Authors 2 | ======= 3 | 4 | A huge thanks to all of our contributors: 5 | 6 | 7 | - =noloh 8 | - Adam Ballai 9 | - Alex Chan 10 | - Alex Rowley 11 | - Brett Gerry 12 | - Bulat Shakirzyanov 13 | - Chris Barr 14 | - D Keith Casey Jr 15 | - D. Keith Casey, Jr. 16 | - Doug Black 17 | - John Britton 18 | - Jordi Boggiano 19 | - Keith Casey 20 | - Kevin Burke 21 | - Kyle 22 | - Kyle Conroy 23 | - Luke Waite 24 | - Neuman 25 | - Neuman Vong 26 | - Peter Meth 27 | - Ryan Brideau 28 | - Sam Kimbrel 29 | - Shawn Parker 30 | - Stuart Langley 31 | - https://github.com/tacman 32 | - Taichiro Yoshida 33 | - Trenton McManus 34 | - aaronfoss 35 | - sashalaundy 36 | - till 37 | -------------------------------------------------------------------------------- /vendor/twilio/sdk/LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (C) 2011, Twilio, Inc. 4 | Copyright (C) 2011, Neuman Vong 5 | 6 | Permission is hereby granted, free of charge, to any person obtaining a copy of 7 | this software and associated documentation files (the "Software"), to deal in 8 | the Software without restriction, including without limitation the rights to 9 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies 10 | of the Software, and to permit persons to whom the Software is furnished to do 11 | so, subject to the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be included in all 14 | copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | SOFTWARE. 23 | -------------------------------------------------------------------------------- /vendor/twilio/sdk/Makefile: -------------------------------------------------------------------------------- 1 | # Twilio API helper library. 2 | # See LICENSE file for copyright and license details. 3 | 4 | define LICENSE 5 | 13 | * @license http://creativecommons.org/licenses/MIT/ MIT 14 | * @link http://pear.php.net/package/Services_Twilio 15 | */ 16 | endef 17 | export LICENSE 18 | 19 | COMPOSER = $(shell which composer) 20 | ifeq ($(strip $(COMPOSER)),) 21 | COMPOSER = php composer.phar 22 | endif 23 | 24 | all: test 25 | 26 | clean: 27 | @rm -rf dist venv 28 | 29 | PHP_FILES = `find dist -name \*.php` 30 | dist: clean 31 | @mkdir dist 32 | @git archive master | (cd dist; tar xf -) 33 | @for php in $(PHP_FILES); do\ 34 | echo "$$LICENSE" > $$php.new; \ 35 | tail -n+2 $$php >> $$php.new; \ 36 | mv $$php.new $$php; \ 37 | done 38 | 39 | test-install: 40 | # Composer: http://getcomposer.org/download/ 41 | $(COMPOSER) install 42 | 43 | install: 44 | pear channel-discover twilio.github.com/pear 45 | pear install twilio/Services_Twilio 46 | 47 | # if these fail, you may need to install the helper library - run "make 48 | # test-install" 49 | test: 50 | @PATH=vendor/bin:$(PATH) phpunit --strict --colors --configuration tests/phpunit.xml; 51 | 52 | venv: 53 | virtualenv venv 54 | 55 | docs-install: venv 56 | . venv/bin/activate; pip install -r docs/requirements.txt 57 | 58 | docs: 59 | . venv/bin/activate; cd docs && make html 60 | 61 | release-install: 62 | pear channel-discover twilio.github.com/pear || true 63 | pear channel-discover pear.pirum-project.org || true 64 | pear install pirum/Pirum || true 65 | pear install XML_Serializer-0.20.2 || true 66 | pear install PEAR_PackageFileManager2 || true 67 | 68 | authors: 69 | echo "Authors\n=======\n\nA huge thanks to all of our contributors:\n\n" > AUTHORS.md 70 | git log --raw | grep "^Author: " | cut -d ' ' -f2- | cut -d '<' -f1 | sed 's/^/- /' | sort | uniq >> AUTHORS.md 71 | 72 | .PHONY: all clean dist test docs docs-install test-install authors 73 | -------------------------------------------------------------------------------- /vendor/twilio/sdk/README.md: -------------------------------------------------------------------------------- 1 | [![Build Status](https://secure.travis-ci.org/twilio/twilio-php.png?branch=master)](http://travis-ci.org/twilio/twilio-php) 2 | 3 | ## Installation 4 | 5 | You can install **twilio-php** via PEAR or by downloading the source. 6 | 7 | #### Via PEAR (>= 1.9.3): 8 | 9 | PEAR is a package manager for PHP. Open a command line and use these PEAR 10 | commands to download the helper library: 11 | 12 | $ pear channel-discover twilio-pear.herokuapp.com/pear 13 | $ pear install twilio/Services_Twilio 14 | 15 | If you get the following message: 16 | 17 | $ -bash: pear: command not found 18 | 19 | you can install PEAR from their website, or download the source directly. 20 | 21 | #### Via Composer: 22 | 23 | **twilio-php** is available on Packagist as the 24 | [`twilio/sdk`](http://packagist.org/packages/twilio/sdk) package. 25 | 26 | #### Via ZIP file: 27 | 28 | [Click here to download the source 29 | (.zip)](https://github.com/twilio/twilio-php/zipball/master) which includes all 30 | dependencies. 31 | 32 | Once you download the library, move the twilio-php folder to your project 33 | directory and then include the library file: 34 | 35 | require '/path/to/twilio-php/Services/Twilio.php'; 36 | 37 | and you're good to go! 38 | 39 | ## A Brief Introduction 40 | 41 | With the twilio-php library, we've simplified interaction with the 42 | Twilio REST API. No need to manually create URLS or parse XML/JSON. 43 | You now interact with resources directly. Follow the [Quickstart 44 | Guide](http://readthedocs.org/docs/twilio-php/en/latest/#quickstart) 45 | to get up and running right now. The [User 46 | Guide](http://readthedocs.org/docs/twilio-php/en/latest/#user-guide) shows you 47 | how to get the most out of **twilio-php**. 48 | 49 | ## Quickstart 50 | 51 | ### Send an SMS 52 | 53 | ```php 54 | account->messages->sendMessage( 64 | '9991231234', // From a valid Twilio number 65 | '8881231234', // Text this number 66 | "Hello monkey!" 67 | ); 68 | 69 | print $message->sid; 70 | ``` 71 | 72 | ### Make a Call 73 | 74 | ```php 75 | account->calls->create( 85 | '9991231234', // From a valid Twilio number 86 | '8881231234', // Call this number 87 | 88 | // Read TwiML at this URL when a call connects (hold music) 89 | 'http://twimlets.com/holdmusic?Bucket=com.twilio.music.ambient' 90 | ); 91 | ``` 92 | 93 | ### Generating TwiML 94 | 95 | To control phone calls, your application needs to output 96 | [TwiML](http://www.twilio.com/docs/api/twiml/ "Twilio Markup Language"). Use 97 | `Services_Twilio_Twiml` to easily create such responses. 98 | 99 | ```php 100 | say('Hello'); 105 | $response->play('https://api.twilio.com/cowbell.mp3', array("loop" => 5)); 106 | print $response; 107 | ``` 108 | 109 | That will output XML that looks like this: 110 | 111 | ```xml 112 | 113 | 114 | Hello 115 | https://api.twilio.com/cowbell.mp3 116 | 117 | ``` 118 | 119 | ## [Full Documentation](http://readthedocs.org/docs/twilio-php/en/latest/ "Twilio PHP Library Documentation") 120 | 121 | The documentation for **twilio-php** is hosted 122 | at Read the Docs. [Click here to read our full 123 | documentation.](http://readthedocs.org/docs/twilio-php/en/latest/ "Twilio PHP 124 | Library Documentation") 125 | 126 | ## Prerequisites 127 | 128 | * PHP >= 5.2.3 129 | * The PHP JSON extension 130 | 131 | ## Reporting Issues 132 | 133 | We would love to hear your feedback. Report issues using the [Github 134 | Issue Tracker](https://github.com/twilio/twilio-php/issues) or email 135 | [help@twilio.com](mailto:help@twilio.com). 136 | 137 | -------------------------------------------------------------------------------- /vendor/twilio/sdk/Services/Twilio/AutoPagingIterator.php: -------------------------------------------------------------------------------- 1 | generator = $generator; 14 | $this->page = $page; 15 | $this->size = $size; 16 | $this->filters = $filters; 17 | $this->items = array(); 18 | 19 | // Save a backup for rewind() 20 | $this->_args = array( 21 | 'page' => $page, 22 | 'size' => $size, 23 | 'filters' => $filters, 24 | ); 25 | } 26 | 27 | public function current() 28 | { 29 | return current($this->items); 30 | } 31 | 32 | public function key() 33 | { 34 | return key($this->items); 35 | } 36 | 37 | /* 38 | * Return the next item in the list, making another HTTP call to the next 39 | * page of resources if necessary. 40 | */ 41 | public function next() 42 | { 43 | try { 44 | $this->loadIfNecessary(); 45 | return next($this->items); 46 | } 47 | catch (Services_Twilio_RestException $e) { 48 | // 20006 is an out of range paging error, everything else is valid 49 | if ($e->getCode() != 20006) { 50 | throw $e; 51 | } 52 | } 53 | } 54 | 55 | /* 56 | * Restore everything to the way it was before we began paging. This gets 57 | * called at the beginning of any foreach() loop 58 | */ 59 | public function rewind() 60 | { 61 | foreach ($this->_args as $arg => $val) { 62 | $this->$arg = $val; 63 | } 64 | $this->items = array(); 65 | $this->next_page_uri = null; 66 | } 67 | 68 | public function count() 69 | { 70 | throw new BadMethodCallException('Not allowed'); 71 | } 72 | 73 | public function valid() 74 | { 75 | try { 76 | $this->loadIfNecessary(); 77 | return key($this->items) !== null; 78 | } 79 | catch (Services_Twilio_RestException $e) { 80 | // 20006 is an out of range paging error, everything else is valid 81 | if ($e->getCode() != 20006) { 82 | throw $e; 83 | } 84 | } 85 | return false; 86 | } 87 | 88 | /* 89 | * Fill $this->items with a new page from the API, if necessary. 90 | */ 91 | protected function loadIfNecessary() 92 | { 93 | if (// Empty because it's the first time or last page was empty 94 | empty($this->items) 95 | // null key when the items list is iterated over completely 96 | || key($this->items) === null 97 | ) { 98 | $page = call_user_func_array($this->generator, array( 99 | $this->page, 100 | $this->size, 101 | $this->filters, 102 | $this->next_page_uri, 103 | )); 104 | $this->next_page_uri = $page->next_page_uri; 105 | $this->items = $page->getItems(); 106 | $this->page = $this->page + 1; 107 | } 108 | } 109 | } 110 | -------------------------------------------------------------------------------- /vendor/twilio/sdk/Services/Twilio/HttpException.php: -------------------------------------------------------------------------------- 1 | array( 16 | "headers" => "", 17 | "timeout" => 60, 18 | "follow_location" => true, 19 | "ignore_errors" => true, 20 | ), 21 | "ssl" => array(), 22 | ); 23 | private $options = array(); 24 | 25 | public function __construct($uri = '', $kwargs = array()) { 26 | $this->uri = $uri; 27 | if (isset($kwargs['debug'])) { 28 | $this->debug = true; 29 | } 30 | if (isset($kwargs['http_options'])) { 31 | $this->options = $kwargs['http_options'] + self::$default_options; 32 | } else { 33 | $this->options = self::$default_options; 34 | } 35 | } 36 | 37 | public function __call($name, $args) { 38 | list($res, $req_headers, $req_body) = $args + array(0, array(), ''); 39 | 40 | $request_options = $this->options; 41 | $url = $this->uri . $res; 42 | 43 | if (isset($req_body) && strlen($req_body) > 0) { 44 | $request_options['http']['content'] = $req_body; 45 | } 46 | 47 | foreach($req_headers as $key => $value) { 48 | $request_options['http']['header'] .= sprintf("%s: %s\r\n", $key, $value); 49 | } 50 | 51 | if (isset($this->auth_header)) { 52 | $request_options['http']['header'] .= $this->auth_header; 53 | } 54 | 55 | $request_options['http']['method'] = strtoupper($name); 56 | $request_options['http']['ignore_errors'] = true; 57 | 58 | if ($this->debug) { 59 | error_log(var_export($request_options, true)); 60 | } 61 | $ctx = stream_context_create($request_options); 62 | $result = file_get_contents($url, false, $ctx); 63 | 64 | if (false === $result) { 65 | throw new Services_Twilio_HttpStreamException( 66 | "Unable to connect to service"); 67 | } 68 | 69 | $status_header = array_shift($http_response_header); 70 | if (1 !== preg_match('#HTTP/\d+\.\d+ (\d+)#', $status_header, $matches)) { 71 | throw new Services_Twilio_HttpStreamException( 72 | "Unable to detect the status code in the HTTP result."); 73 | } 74 | 75 | $status_code = intval($matches[1]); 76 | $response_headers = array(); 77 | 78 | foreach($http_response_header as $header) { 79 | list($key, $val) = explode(":", $header); 80 | $response_headers[trim($key)] = trim($val); 81 | } 82 | 83 | return array($status_code, $response_headers, $result); 84 | } 85 | 86 | public function authenticate($user, $pass) { 87 | if (isset($user) && isset($pass)) { 88 | $this->auth_header = sprintf("Authorization: Basic %s", 89 | base64_encode(sprintf("%s:%s", $user, $pass))); 90 | } else { 91 | $this->auth_header = null; 92 | } 93 | } 94 | } 95 | -------------------------------------------------------------------------------- /vendor/twilio/sdk/Services/Twilio/InstanceResource.php: -------------------------------------------------------------------------------- 1 | 7 | * @license http://creativecommons.org/licenses/MIT/ MIT 8 | * @link http://pear.php.net/package/Services_Twilio 9 | */ 10 | 11 | /** 12 | * Abstraction of an instance resource from the Twilio API. 13 | */ 14 | abstract class Services_Twilio_InstanceResource extends Services_Twilio_Resource { 15 | 16 | /** 17 | * Make a request to the API to update an instance resource 18 | * 19 | * :param mixed $params: An array of updates, or a property name 20 | * :param mixed $value: A value with which to update the resource 21 | * 22 | * :rtype: null 23 | * :throws: a :php:class:`RestException ` if 24 | * the update fails. 25 | */ 26 | public function update($params, $value = null) 27 | { 28 | if (!is_array($params)) { 29 | $params = array($params => $value); 30 | } 31 | $decamelizedParams = $this->client->createData($this->uri, $params); 32 | $this->updateAttributes($decamelizedParams); 33 | } 34 | 35 | /* 36 | * Add all properties from an associative array (the JSON response body) as 37 | * properties on this instance resource, except the URI 38 | * 39 | * :param stdClass $params: An object containing all of the parameters of 40 | * this instance 41 | * :return: Nothing, this is purely side effecting 42 | * :rtype: null 43 | */ 44 | public function updateAttributes($params) { 45 | unset($params->uri); 46 | foreach ($params as $name => $value) { 47 | $this->$name = $value; 48 | } 49 | } 50 | 51 | /** 52 | * Get the value of a property on this resource. 53 | * 54 | * Instead of defining all of the properties of an object directly, we rely 55 | * on the API to tell us which properties an object has. This method will 56 | * query the API to retrieve a property for an object, if it is not already 57 | * set on the object. 58 | * 59 | * If the call is to a subresource, eg ``$client->account->messages``, no 60 | * request is made. 61 | * 62 | * To help with lazy HTTP requests, we don't actually retrieve an object 63 | * from the API unless you really need it. Hence, this function may make API 64 | * requests even if the property you're requesting isn't available on the 65 | * resource. 66 | * 67 | * :param string $key: The property name 68 | * 69 | * :return mixed: Could be anything. 70 | * :throws: a :php:class:`RestException ` if 71 | * the update fails. 72 | */ 73 | public function __get($key) 74 | { 75 | if ($subresource = $this->getSubresources($key)) { 76 | return $subresource; 77 | } 78 | if (!isset($this->$key)) { 79 | $params = $this->client->retrieveData($this->uri); 80 | $this->updateAttributes($params); 81 | } 82 | return $this->$key; 83 | } 84 | } 85 | -------------------------------------------------------------------------------- /vendor/twilio/sdk/Services/Twilio/NumberType.php: -------------------------------------------------------------------------------- 1 | instance_name = 'Services_Twilio_Rest_IncomingPhoneNumber'; 7 | return $camelized ? 'IncomingPhoneNumbers' : 'incoming_phone_numbers'; 8 | } 9 | 10 | /** 11 | * Purchase a new phone number. 12 | * 13 | * Example usage: 14 | * 15 | * .. code-block:: php 16 | * 17 | * $marlosBurner = '+14105551234'; 18 | * $client->account->incoming_phone_numbers->local->purchase($marlosBurner); 19 | * 20 | * :param string $phone_number: The phone number to purchase 21 | * :param array $params: An optional array of parameters to pass along with 22 | * the request (to configure the phone number) 23 | */ 24 | public function purchase($phone_number, array $params = array()) { 25 | $postParams = array( 26 | 'PhoneNumber' => $phone_number 27 | ); 28 | return $this->create($postParams + $params); 29 | } 30 | 31 | public function create(array $params = array()) { 32 | return parent::_create($params); 33 | } 34 | 35 | } 36 | -------------------------------------------------------------------------------- /vendor/twilio/sdk/Services/Twilio/Page.php: -------------------------------------------------------------------------------- 1 | 9 | * @license http://creativecommons.org/licenses/MIT/ MIT 10 | * @link http://pear.php.net/package/Services_Twilio 11 | */ 12 | class Services_Twilio_Page 13 | implements IteratorAggregate 14 | { 15 | 16 | /** 17 | * The item list. 18 | * 19 | * @var array $items 20 | */ 21 | protected $items; 22 | 23 | /** 24 | * Constructs a page. 25 | * 26 | * @param object $page The page object 27 | * @param string $name The key of the item list 28 | */ 29 | public function __construct($page, $name, $next_page_uri = null) 30 | { 31 | $this->page = $page; 32 | $this->items = $page->{$name}; 33 | $this->next_page_uri = $next_page_uri; 34 | } 35 | 36 | /** 37 | * The item list of the page. 38 | * 39 | * @return array A list of instance resources 40 | */ 41 | public function getItems() 42 | { 43 | return $this->items; 44 | } 45 | 46 | /** 47 | * Magic method to allow retrieving the properties of the wrapped page. 48 | * 49 | * @param string $prop The property name 50 | * 51 | * @return mixed Could be anything 52 | */ 53 | public function __get($prop) 54 | { 55 | return $this->page->$prop; 56 | } 57 | 58 | /** 59 | * Implementation of IteratorAggregate::getIterator(). 60 | * 61 | * @return Traversable 62 | */ 63 | public function getIterator() 64 | { 65 | return $this->getItems(); 66 | } 67 | } 68 | 69 | -------------------------------------------------------------------------------- /vendor/twilio/sdk/Services/Twilio/PartialApplicationHelper.php: -------------------------------------------------------------------------------- 1 | 10 | * @license http://creativecommons.org/licenses/MIT/ MIT 11 | * @link http://pear.php.net/package/Services_Twilio 12 | */ 13 | class Services_Twilio_PartialApplicationHelper 14 | { 15 | private $callbacks; 16 | 17 | public function __construct() 18 | { 19 | $this->callbacks = array(); 20 | } 21 | 22 | public function set($method, $callback, array $args) 23 | { 24 | if (!is_callable($callback)) { 25 | return FALSE; 26 | } 27 | $this->callbacks[$method] = array($callback, $args); 28 | } 29 | 30 | public function __call($method, $args) 31 | { 32 | if (!isset($this->callbacks[$method])) { 33 | throw new Exception("Method not found: $method"); 34 | } 35 | list($callback, $cb_args) = $this->callbacks[$method]; 36 | return call_user_func_array( 37 | $callback, 38 | array_merge($cb_args, $args) 39 | ); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /vendor/twilio/sdk/Services/Twilio/RequestValidator.php: -------------------------------------------------------------------------------- 1 | AuthToken = $token; 11 | } 12 | 13 | public function computeSignature($url, $data = array()) 14 | { 15 | // sort the array by keys 16 | ksort($data); 17 | 18 | // append them to the data string in order 19 | // with no delimiters 20 | foreach($data as $key => $value) 21 | $url .= "$key$value"; 22 | 23 | // This function calculates the HMAC hash of the data with the key 24 | // passed in 25 | // Note: hash_hmac requires PHP 5 >= 5.1.2 or PECL hash:1.1-1.5 26 | // Or http://pear.php.net/package/Crypt_HMAC/ 27 | return base64_encode(hash_hmac("sha1", $url, $this->AuthToken, true)); 28 | } 29 | 30 | public function validate($expectedSignature, $url, $data = array()) 31 | { 32 | return $this->computeSignature($url, $data) 33 | == $expectedSignature; 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /vendor/twilio/sdk/Services/Twilio/Resource.php: -------------------------------------------------------------------------------- 1 | 9 | * @license http://creativecommons.org/licenses/MIT/ MIT 10 | * @link http://pear.php.net/package/Services_Twilio 11 | */ 12 | abstract class Services_Twilio_Resource { 13 | protected $subresources; 14 | 15 | public function __construct($client, $uri, $params = array()) 16 | { 17 | $this->subresources = array(); 18 | $this->client = $client; 19 | 20 | foreach ($params as $name => $param) { 21 | $this->$name = $param; 22 | } 23 | 24 | $this->uri = $uri; 25 | $this->init($client, $uri); 26 | } 27 | 28 | protected function init($client, $uri) 29 | { 30 | // Left empty for derived classes to implement 31 | } 32 | 33 | public function getSubresources($name = null) { 34 | if (isset($name)) { 35 | return isset($this->subresources[$name]) 36 | ? $this->subresources[$name] 37 | : null; 38 | } 39 | return $this->subresources; 40 | } 41 | 42 | protected function setupSubresources() 43 | { 44 | foreach (func_get_args() as $name) { 45 | $constantized = ucfirst(self::camelize($name)); 46 | $type = "Services_Twilio_Rest_" . $constantized; 47 | $this->subresources[$name] = new $type( 48 | $this->client, $this->uri . "/$constantized" 49 | ); 50 | } 51 | } 52 | 53 | /* 54 | * Get the resource name from the classname 55 | * 56 | * Ex: Services_Twilio_Rest_Accounts -> Accounts 57 | * 58 | * @param boolean $camelized Whether to return camel case or not 59 | */ 60 | public function getResourceName($camelized = false) 61 | { 62 | $name = get_class($this); 63 | $parts = explode('_', $name); 64 | $basename = end($parts); 65 | if ($camelized) { 66 | return $basename; 67 | } else { 68 | return self::decamelize($basename); 69 | } 70 | } 71 | 72 | public static function decamelize($word) 73 | { 74 | $callback = create_function('$matches', 75 | 'return strtolower(strlen("$matches[1]") ? "$matches[1]_$matches[2]" : "$matches[2]");'); 76 | 77 | return preg_replace_callback( 78 | '/(^|[a-z])([A-Z])/', 79 | $callback, 80 | $word 81 | ); 82 | } 83 | 84 | /** 85 | * Return camelized version of a word 86 | * Examples: sms_messages => SMSMessages, calls => Calls, 87 | * incoming_phone_numbers => IncomingPhoneNumbers 88 | * 89 | * @param string $word The word to camelize 90 | * @return string 91 | */ 92 | public static function camelize($word) { 93 | $callback = create_function('$matches', 'return strtoupper("$matches[2]");'); 94 | 95 | return preg_replace_callback('/(^|_)([a-z])/', 96 | $callback, 97 | $word); 98 | } 99 | 100 | /** 101 | * Get the value of a property on this resource. 102 | * 103 | * @param string $key The property name 104 | * @return mixed Could be anything. 105 | */ 106 | public function __get($key) { 107 | if ($subresource = $this->getSubresources($key)) { 108 | return $subresource; 109 | } 110 | return $this->$key; 111 | } 112 | 113 | /** 114 | * Print a JSON representation of this object. Strips the HTTP client 115 | * before returning. 116 | * 117 | * Note, this should mainly be used for debugging, and is not guaranteed 118 | * to correspond 1:1 with the JSON API output. 119 | * 120 | * Note that echoing an object before an HTTP request has been made to 121 | * "fill in" its properties may return an empty object 122 | */ 123 | public function __toString() { 124 | $out = array(); 125 | foreach ($this as $key => $value) { 126 | if ($key !== 'client' && $key !== 'subresources') { 127 | $out[$key] = $value; 128 | } 129 | } 130 | return json_encode($out, true); 131 | } 132 | 133 | } 134 | 135 | -------------------------------------------------------------------------------- /vendor/twilio/sdk/Services/Twilio/Rest/Account.php: -------------------------------------------------------------------------------- 1 | setupSubresources( 7 | 'applications', 8 | 'available_phone_numbers', 9 | 'outgoing_caller_ids', 10 | 'calls', 11 | 'conferences', 12 | 'incoming_phone_numbers', 13 | 'media', 14 | 'messages', 15 | 'notifications', 16 | 'outgoing_callerids', 17 | 'recordings', 18 | 'sms_messages', 19 | 'short_codes', 20 | 'transcriptions', 21 | 'connect_apps', 22 | 'authorized_connect_apps', 23 | 'usage_records', 24 | 'usage_triggers', 25 | 'queues', 26 | 'sip' 27 | ); 28 | 29 | $this->sandbox = new Services_Twilio_Rest_Sandbox( 30 | $client, $uri . '/Sandbox' 31 | ); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /vendor/twilio/sdk/Services/Twilio/Rest/Accounts.php: -------------------------------------------------------------------------------- 1 | `_ documentation. 6 | */ 7 | class Services_Twilio_Rest_Accounts extends Services_Twilio_ListResource { 8 | 9 | /** 10 | * Create a new subaccount. 11 | * 12 | * :param array $params: An array of parameters describing the new 13 | * subaccount. The ``$params`` array can contain the following keys: 14 | * 15 | * *FriendlyName* 16 | * A description of this account, up to 64 characters long 17 | * 18 | * :returns: The new subaccount 19 | * :rtype: :php:class:`Services_Twilio_Rest_Account` 20 | * 21 | */ 22 | public function create($params = array()) { 23 | return parent::_create($params); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /vendor/twilio/sdk/Services/Twilio/Rest/Application.php: -------------------------------------------------------------------------------- 1 | $name 10 | ) + $params); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /vendor/twilio/sdk/Services/Twilio/Rest/AuthorizedConnectApp.php: -------------------------------------------------------------------------------- 1 | set( 9 | 'getList', 10 | array($this, 'getList'), 11 | array($country, 'Local') 12 | ); 13 | return $curried; 14 | } 15 | public function getTollFree($country) { 16 | $curried = new Services_Twilio_PartialApplicationHelper(); 17 | $curried->set( 18 | 'getList', 19 | array($this, 'getList'), 20 | array($country, 'TollFree') 21 | ); 22 | return $curried; 23 | } 24 | 25 | public function getMobile($country) 26 | { 27 | $curried = new Services_Twilio_PartialApplicationHelper(); 28 | $curried->set( 29 | 'getList', 30 | array($this, 'getList'), 31 | array($country, 'Mobile') 32 | ); 33 | return $curried; 34 | } 35 | 36 | /** 37 | * Get a list of available phone numbers. 38 | * 39 | * @param string $country The 2-digit country code you'd like to search for 40 | * numbers e.g. ('US', 'CA', 'GB') 41 | * @param string $type The type of number ('Local', 'TollFree', or 'Mobile') 42 | * @return object The object representation of the resource 43 | */ 44 | public function getList($country, $type, array $params = array()) 45 | { 46 | return $this->client->retrieveData($this->uri . "/$country/$type", $params); 47 | } 48 | 49 | public function getResourceName($camelized = false) { 50 | // You can't page through the list of available phone numbers. 51 | $this->instance_name = 'Services_Twilio_Rest_AvailablePhoneNumber'; 52 | return $camelized ? 'Countries' : 'countries'; 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /vendor/twilio/sdk/Services/Twilio/Rest/Call.php: -------------------------------------------------------------------------------- 1 | `_ documentation. 5 | * 6 | * .. php:attr:: sid 7 | * 8 | * A 34 character string that uniquely identifies this resource. 9 | * 10 | * .. php:attr:: parent_call_sid 11 | * 12 | * A 34 character string that uniquely identifies the call that created this leg. 13 | * 14 | * .. php:attr:: date_created 15 | * 16 | * The date that this resource was created, given as GMT in RFC 2822 format. 17 | * 18 | * .. php:attr:: date_updated 19 | * 20 | * The date that this resource was last updated, given as GMT in RFC 2822 format. 21 | * 22 | * .. php:attr:: account_sid 23 | * 24 | * The unique id of the Account responsible for creating this call. 25 | * 26 | * .. php:attr:: to 27 | * 28 | * The phone number that received this call. e.g., +16175551212 (E.164 format) 29 | * 30 | * .. php:attr:: from 31 | * 32 | * The phone number that made this call. e.g., +16175551212 (E.164 format) 33 | * 34 | * .. php:attr:: phone_number_sid 35 | * 36 | * If the call was inbound, this is the Sid of the IncomingPhoneNumber that 37 | * received the call. If the call was outbound, it is the Sid of the 38 | * OutgoingCallerId from which the call was placed. 39 | * 40 | * .. php:attr:: status 41 | * 42 | * A string representing the status of the call. May be `QUEUED`, `RINGING`, 43 | * `IN-PROGRESS`, `COMPLETED`, `FAILED`, `BUSY` or `NO_ANSWER`. 44 | * 45 | * .. php:attr:: stat_time 46 | * 47 | * The start time of the call, given as GMT in RFC 2822 format. Empty if the call has not yet been dialed. 48 | * 49 | * .. php:attr:: end_time 50 | * 51 | * The end time of the call, given as GMT in RFC 2822 format. Empty if the call did not complete successfully. 52 | * 53 | * .. php:attr:: duration 54 | * 55 | * The length of the call in seconds. This value is empty for busy, failed, unanswered or ongoing calls. 56 | * 57 | * .. php:attr:: price 58 | * 59 | * The charge for this call in USD. Populated after the call is completed. May not be immediately available. 60 | * 61 | * .. php:attr:: direction 62 | * 63 | * A string describing the direction of the call. inbound for inbound 64 | * calls, outbound-api for calls initiated via the REST API or 65 | * outbound-dial for calls initiated by a verb. 66 | * 67 | * .. php:attr:: answered_by 68 | * 69 | * If this call was initiated with answering machine detection, either human or machine. Empty otherwise. 70 | * 71 | * .. php:attr:: forwarded_from 72 | * 73 | * If this call was an incoming call forwarded from another number, the 74 | * forwarding phone number (depends on carrier supporting forwarding). 75 | * Empty otherwise. 76 | * 77 | * .. php:attr:: caller_name 78 | * 79 | * If this call was an incoming call from a phone number with Caller ID Lookup enabled, the caller's name. Empty otherwise. 80 | */ 81 | class Services_Twilio_Rest_Call extends Services_Twilio_InstanceResource { 82 | 83 | /** 84 | * Hang up the call 85 | */ 86 | public function hangup() { 87 | $this->update('Status', 'completed'); 88 | } 89 | 90 | /** 91 | * Redirect the call to a new URL 92 | * 93 | * :param string $url: the new URL to retrieve call flow from. 94 | */ 95 | public function route($url) { 96 | $this->update('Url', $url); 97 | } 98 | 99 | protected function init($client, $uri) { 100 | $this->setupSubresources( 101 | 'notifications', 102 | 'recordings' 103 | ); 104 | } 105 | } 106 | -------------------------------------------------------------------------------- /vendor/twilio/sdk/Services/Twilio/Rest/Calls.php: -------------------------------------------------------------------------------- 1 | setupSubresources( 9 | 'participants' 10 | ); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /vendor/twilio/sdk/Services/Twilio/Rest/Conferences.php: -------------------------------------------------------------------------------- 1 | setupSubresources( 38 | 'credentials' 39 | ); 40 | } 41 | } 42 | 43 | -------------------------------------------------------------------------------- /vendor/twilio/sdk/Services/Twilio/Rest/CredentialListMapping.php: -------------------------------------------------------------------------------- 1 | setupSubresources( 34 | 'credentials' 35 | ); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /vendor/twilio/sdk/Services/Twilio/Rest/CredentialListMappings.php: -------------------------------------------------------------------------------- 1 | account->sip->domains->get('SDXXX')->credential_list_mappings->create("CLXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"); 13 | * 14 | * :param string $credential_list_sid: the sid of the CredentialList you're adding to this domain. 15 | * :param array $params: a single array of parameters which is serialized and 16 | * sent directly to the Twilio API. 17 | */ 18 | public function create($credential_list_sid, $params = array()) { 19 | return parent::_create(array( 20 | 'CredentialListSid' => $credential_list_sid, 21 | ) + $params); 22 | } 23 | } 24 | 25 | -------------------------------------------------------------------------------- /vendor/twilio/sdk/Services/Twilio/Rest/CredentialLists.php: -------------------------------------------------------------------------------- 1 | account->sip->credential_lists->create("MyFriendlyName"); 13 | * 14 | * :param string $friendly_name: the friendly name of this credential list 15 | * :param array $params: a single array of parameters which is serialized and 16 | * sent directly to the Twilio API. 17 | */ 18 | public function create($friendly_name, $params = array()) { 19 | return parent::_create(array( 20 | 'FriendlyName' => $friendly_name, 21 | ) + $params); 22 | } 23 | 24 | } 25 | -------------------------------------------------------------------------------- /vendor/twilio/sdk/Services/Twilio/Rest/Credentials.php: -------------------------------------------------------------------------------- 1 | account->sip->credential_lists->get('CLXXX')->credentials->create( 13 | * "AwesomeUsername", "SuperSecretPassword", 14 | * ); 15 | * 16 | * :param string $username: the username for the new Credential object 17 | * :param string $password: the password for the new Credential object 18 | * :param array $params: a single array of parameters which is serialized and 19 | * sent directly to the Twilio API. 20 | */ 21 | public function create($username, $password, $params = array()) { 22 | return parent::_create(array( 23 | 'Username' => $username, 24 | 'Password' => $password, 25 | ) + $params); 26 | } 27 | 28 | } 29 | -------------------------------------------------------------------------------- /vendor/twilio/sdk/Services/Twilio/Rest/Domain.php: -------------------------------------------------------------------------------- 1 | setupSubresources( 66 | 'ip_access_control_list_mappings', 67 | 'credential_list_mappings' 68 | ); 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /vendor/twilio/sdk/Services/Twilio/Rest/Domains.php: -------------------------------------------------------------------------------- 1 | account->sip->domains->create( 13 | * "MyFriendlyName", "MyDomainName" 14 | * ); 15 | * 16 | * :param string $friendly_name: the friendly name of this domain 17 | * :param string $domain_name: the domain name for this domain 18 | * :param array $params: a single array of parameters which is serialized and 19 | * sent directly to the Twilio API. 20 | */ 21 | public function create($friendly_name, $domain_name, $params = array()) { 22 | return parent::_create(array( 23 | 'FriendlyName' => $friendly_name, 24 | 'DomainName' => $domain_name, 25 | ) + $params); 26 | } 27 | } 28 | 29 | -------------------------------------------------------------------------------- /vendor/twilio/sdk/Services/Twilio/Rest/IncomingPhoneNumber.php: -------------------------------------------------------------------------------- 1 | `_ 7 | * documentation. 8 | * 9 | * .. php:attr:: sid 10 | * 11 | * A 34 character string that uniquely idetifies this resource. 12 | * 13 | * .. php:attr:: date_created 14 | * 15 | * The date that this resource was created, given as GMT RFC 2822 format. 16 | * 17 | * .. php:attr:: date_updated 18 | * 19 | * The date that this resource was last updated, given as GMT RFC 2822 format. 20 | * 21 | * .. php:attr:: friendly_name 22 | * 23 | * A human readable descriptive text for this resource, up to 64 24 | * characters long. By default, the FriendlyName is a nicely formatted 25 | * version of the phone number. 26 | * 27 | * .. php:attr:: account_sid 28 | * 29 | * The unique id of the Account responsible for this phone number. 30 | * 31 | * .. php:attr:: phone_number 32 | * 33 | * The incoming phone number. e.g., +16175551212 (E.164 format) 34 | * 35 | * .. php:attr:: api_version 36 | * 37 | * Calls to this phone number will start a new TwiML session with this 38 | * API version. 39 | * 40 | * .. php:attr:: voice_caller_id_lookup 41 | * 42 | * Look up the caller's caller-ID name from the CNAM database (additional charges apply). Either true or false. 43 | * 44 | * .. php:attr:: voice_url 45 | * 46 | * The URL Twilio will request when this phone number receives a call. 47 | * 48 | * .. php:attr:: voice_method 49 | * 50 | * The HTTP method Twilio will use when requesting the above Url. Either GET or POST. 51 | * 52 | * .. php:attr:: voice_fallback_url 53 | * 54 | * The URL that Twilio will request if an error occurs retrieving or executing the TwiML requested by Url. 55 | * 56 | * .. php:attr:: voice_fallback_method 57 | * 58 | * The HTTP method Twilio will use when requesting the VoiceFallbackUrl. Either GET or POST. 59 | * 60 | * .. php:attr:: status_callback 61 | * 62 | * The URL that Twilio will request to pass status parameters (such as call ended) to your application. 63 | * 64 | * .. php:attr:: status_callback_method 65 | * 66 | * The HTTP method Twilio will use to make requests to the StatusCallback URL. Either GET or POST. 67 | * 68 | * .. php:attr:: sms_url 69 | * 70 | * The URL Twilio will request when receiving an incoming SMS message to this number. 71 | * 72 | * .. php:attr:: sms_method 73 | * 74 | * The HTTP method Twilio will use when making requests to the SmsUrl. Either GET or POST. 75 | * 76 | * .. php:attr:: sms_fallback_url 77 | * 78 | * The URL that Twilio will request if an error occurs retrieving or executing the TwiML from SmsUrl. 79 | * 80 | * .. php:attr:: sms_fallback_method 81 | * 82 | * The HTTP method Twilio will use when requesting the above URL. Either GET or POST. 83 | * 84 | * .. php:attr:: uri 85 | * 86 | * The URI for this resource, relative to https://api.twilio.com. 87 | */ 88 | class Services_Twilio_Rest_IncomingPhoneNumber 89 | extends Services_Twilio_InstanceResource 90 | { 91 | } 92 | -------------------------------------------------------------------------------- /vendor/twilio/sdk/Services/Twilio/Rest/IncomingPhoneNumbers.php: -------------------------------------------------------------------------------- 1 | `_ 7 | * documentation at twilio.com. 8 | */ 9 | class Services_Twilio_Rest_IncomingPhoneNumbers extends Services_Twilio_ListResource { 10 | function init($client, $uri) { 11 | $this->setupSubresources( 12 | 'local', 13 | 'toll_free', 14 | 'mobile' 15 | ); 16 | } 17 | 18 | function create(array $params = array()) { 19 | return parent::_create($params); 20 | } 21 | 22 | function getList($type, array $params = array()) 23 | { 24 | return $this->client->retrieveData($this->uri . "/$type", $params); 25 | } 26 | 27 | /** 28 | * Return a phone number instance from its E.164 representation. If more 29 | * than one number matches the search string, returns the first one. 30 | * 31 | * Example usage: 32 | * 33 | * .. code-block:: php 34 | * 35 | * $number = $client->account->incoming_phone_numbers->getNumber('+14105551234'); 36 | * echo $number->sid; 37 | * 38 | * :param string $number: The number in E.164 format, eg "+684105551234" 39 | * :return: A :php:class:`Services_Twilio_Rest_IncomingPhoneNumber` object, or null 40 | * :raises: a A :php:class:`Services_Twilio_RestException` if the number is 41 | * invalid, not provided in E.164 format or for any other API exception. 42 | */ 43 | public function getNumber($number) { 44 | $page = $this->getPage(0, 1, array( 45 | 'PhoneNumber' => $number 46 | )); 47 | $items = $page->getItems(); 48 | if (is_null($items) || empty($items)) { 49 | return null; 50 | } 51 | return $items[0]; 52 | } 53 | } 54 | 55 | class Services_Twilio_Rest_Local extends Services_Twilio_NumberType { } 56 | 57 | class Services_Twilio_Rest_Mobile extends Services_Twilio_NumberType { } 58 | 59 | class Services_Twilio_Rest_TollFree extends Services_Twilio_NumberType { } 60 | -------------------------------------------------------------------------------- /vendor/twilio/sdk/Services/Twilio/Rest/IpAccessControlList.php: -------------------------------------------------------------------------------- 1 | setupSubresources( 37 | 'ip_addresses' 38 | ); 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /vendor/twilio/sdk/Services/Twilio/Rest/IpAccessControlListMapping.php: -------------------------------------------------------------------------------- 1 | setupSubresources( 33 | 'ip_addresses' 34 | ); 35 | } 36 | } 37 | 38 | -------------------------------------------------------------------------------- /vendor/twilio/sdk/Services/Twilio/Rest/IpAccessControlListMappings.php: -------------------------------------------------------------------------------- 1 | account->sip->domains->get('SDXXX')->ip_access_control_list_mappings->create("ALXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"); 13 | * 14 | * :param string $ip_access_control_list_sid: the sid of the IpAccessControList 15 | * you're adding to this domain. 16 | * :param array $params: a single array of parameters which is serialized and 17 | * sent directly to the Twilio API. 18 | */ 19 | public function create($ip_access_control_list_sid, $params = array()) { 20 | return parent::_create(array( 21 | 'IpAccessControlListSid' => $ip_access_control_list_sid, 22 | ) + $params); 23 | } 24 | } 25 | 26 | -------------------------------------------------------------------------------- /vendor/twilio/sdk/Services/Twilio/Rest/IpAccessControlLists.php: -------------------------------------------------------------------------------- 1 | account->sip->ip_access_control_lists->create("MyFriendlyName"); 13 | * 14 | * :param string $friendly_name: the friendly name of this ip access control list 15 | * :param array $params: a single array of parameters which is serialized and 16 | * sent directly to the Twilio API. 17 | * :return: the created list 18 | * :rtype: :class:`Services_Twilio_Rest_IpAccessControlList` 19 | * 20 | */ 21 | public function create($friendly_name, $params = array()) { 22 | return parent::_create(array( 23 | 'FriendlyName' => $friendly_name, 24 | ) + $params); 25 | } 26 | 27 | } 28 | -------------------------------------------------------------------------------- /vendor/twilio/sdk/Services/Twilio/Rest/IpAddress.php: -------------------------------------------------------------------------------- 1 | instance_name = "Services_Twilio_Rest_IpAddress"; 7 | parent::__construct($client, $uri); 8 | } 9 | 10 | /** 11 | * Creates a new IpAddress instance 12 | * 13 | * Example usage: 14 | * 15 | * .. code-block:: php 16 | * 17 | * $client->account->sip->ip_access_control_lists->get('ALXXX')->ip_addresses->create( 18 | * "FriendlyName", "127.0.0.1" 19 | * ); 20 | * 21 | * :param string $friendly_name: the friendly name for the new IpAddress object 22 | * :param string $ip_address: the ip address for the new IpAddress object 23 | * :param array $params: a single array of parameters which is serialized and 24 | * sent directly to the Twilio API. 25 | */ 26 | public function create($friendly_name, $ip_address, $params = array()) { 27 | return parent::_create(array( 28 | 'FriendlyName' => $friendly_name, 29 | 'IpAddress' => $ip_address, 30 | ) + $params); 31 | } 32 | } 33 | 34 | -------------------------------------------------------------------------------- /vendor/twilio/sdk/Services/Twilio/Rest/Media.php: -------------------------------------------------------------------------------- 1 | ` objects. 5 | * For the definitive reference, see the `Twilio Media List Documentation 6 | * `_. 7 | */ 8 | class Services_Twilio_Rest_Media extends Services_Twilio_ListResource { 9 | 10 | 11 | // This is overridden because the list key in the Twilio response 12 | // is "media_list", not "media". 13 | public function getResourceName($camelized = false) 14 | { 15 | if ($camelized) { 16 | return "MediaList"; 17 | } else { 18 | return "media_list"; 19 | } 20 | } 21 | 22 | // We manually set the instance name here so that the parent 23 | // constructor doesn't attempt to figure out it. It would do it 24 | // incorrectly because we override getResourceName above. 25 | public function __construct($client, $uri) { 26 | $this->instance_name = "Services_Twilio_Rest_MediaInstance"; 27 | parent::__construct($client, $uri); 28 | } 29 | 30 | } 31 | 32 | -------------------------------------------------------------------------------- /vendor/twilio/sdk/Services/Twilio/Rest/MediaInstance.php: -------------------------------------------------------------------------------- 1 | `_. 6 | * 7 | * .. php:attr:: sid 8 | * 9 | * A 34 character string that identifies this object 10 | * 11 | * .. php:attr:: account_sid 12 | * 13 | * A 34 character string representing the account that sent the message 14 | * 15 | * .. php:attr:: parent_sid 16 | * 17 | * The sid of the message that created this media. 18 | * 19 | * .. php:attr:: date_created 20 | * 21 | * The date the message was created 22 | * 23 | * .. php:attr:: date_updated 24 | * 25 | * The date the message was updated 26 | * 27 | * .. php:attr:: content_type 28 | * 29 | * The content-type of the media. 30 | */ 31 | class Services_Twilio_Rest_MediaInstance extends Services_Twilio_InstanceResource { 32 | public function __construct($client, $uri) { 33 | $uri = str_replace('MediaInstance', 'Media', $uri); 34 | parent::__construct($client, $uri); 35 | } 36 | } 37 | 38 | -------------------------------------------------------------------------------- /vendor/twilio/sdk/Services/Twilio/Rest/Member.php: -------------------------------------------------------------------------------- 1 | $url, 19 | 'Method' => $method, 20 | )); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /vendor/twilio/sdk/Services/Twilio/Rest/Members.php: -------------------------------------------------------------------------------- 1 | instance_name($this->client, $this->uri . '/Front'); 15 | } 16 | 17 | /* Participants are identified by CallSid, not like ME123 */ 18 | public function getObjectFromJson($params, $idParam = 'sid') { 19 | return parent::getObjectFromJson($params, 'call_sid'); 20 | } 21 | 22 | public function getResourceName($camelized = false) 23 | { 24 | // The JSON property name is atypical. 25 | return $camelized ? 'Members' : 'queue_members'; 26 | } 27 | } 28 | 29 | -------------------------------------------------------------------------------- /vendor/twilio/sdk/Services/Twilio/Rest/Message.php: -------------------------------------------------------------------------------- 1 | setupSubresources( 49 | 'media' 50 | ); 51 | } 52 | } 53 | 54 | -------------------------------------------------------------------------------- /vendor/twilio/sdk/Services/Twilio/Rest/Messages.php: -------------------------------------------------------------------------------- 1 | account->messages->create(array( 13 | * "Body" => "foo", 14 | * "From" => "+14105551234", 15 | * "To" => "+14105556789", 16 | * )); 17 | * 18 | * :param array $params: a single array of parameters which is serialized and 19 | * sent directly to the Twilio API. You may find it easier to use the 20 | * sendMessage helper instead of this function. 21 | * 22 | */ 23 | public function create($params = array()) { 24 | return parent::_create($params); 25 | } 26 | 27 | /** 28 | * Send a message 29 | * 30 | * .. code-block:: php 31 | * 32 | * $client = new Services_Twilio('AC123', '123'); 33 | * $message = $client->account->messages->sendMessage( 34 | * '+14105551234', // From a Twilio number in your account 35 | * '+14105556789', // Text any number 36 | * 'Come at the king, you best not miss.' // Message body (if any) 37 | * array('https://demo.twilio.com/owl.png'), // An array of MediaUrls 38 | * ); 39 | * 40 | * :param string $from: the from number for the message, this must be a 41 | * number you purchased from Twilio 42 | * :param string $to: the message recipient's phone number 43 | * :param $mediaUrls: the URLs of images to send in this MMS 44 | * :type $mediaUrls: null (don't include media), a single URL, or an array 45 | * of URLs to send as media with this message 46 | * :param string $body: the text to include along with this MMS 47 | * :param array $params: Any additional params (callback, etc) you'd like to 48 | * send with this request, these are serialized and sent as POST 49 | * parameters 50 | * 51 | * :return: The created :class:`Services_Twilio_Rest_Message` 52 | * :raises: :class:`Services_Twilio_RestException` 53 | * An exception if the parameters are invalid (for example, the from 54 | * number is not a Twilio number registered to your account, or is 55 | * unable to send MMS) 56 | */ 57 | public function sendMessage($from, $to, $body = null, $mediaUrls = null, 58 | $params = array() 59 | ) { 60 | $postParams = array( 61 | 'From' => $from, 62 | 'To' => $to, 63 | ); 64 | // When the request is made, this will get serialized into MediaUrl=a&MediaUrl=b 65 | if (!is_null($mediaUrls)) { 66 | $postParams['MediaUrl'] = $mediaUrls; 67 | } 68 | if (!is_null($body)) { 69 | $postParams['Body'] = $body; 70 | } 71 | return self::create($postParams + $params); 72 | } 73 | } 74 | -------------------------------------------------------------------------------- /vendor/twilio/sdk/Services/Twilio/Rest/Notification.php: -------------------------------------------------------------------------------- 1 | $phoneNumber, 10 | ) + $params); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /vendor/twilio/sdk/Services/Twilio/Rest/Participant.php: -------------------------------------------------------------------------------- 1 | update('Muted', 'true'); 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /vendor/twilio/sdk/Services/Twilio/Rest/Participants.php: -------------------------------------------------------------------------------- 1 | setupSubresources('members'); 8 | } 9 | } 10 | 11 | -------------------------------------------------------------------------------- /vendor/twilio/sdk/Services/Twilio/Rest/Queues.php: -------------------------------------------------------------------------------- 1 | $friendly_name, 16 | ) + $params); 17 | } 18 | } 19 | 20 | -------------------------------------------------------------------------------- /vendor/twilio/sdk/Services/Twilio/Rest/Recording.php: -------------------------------------------------------------------------------- 1 | setupSubresources('transcriptions'); 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /vendor/twilio/sdk/Services/Twilio/Rest/Recordings.php: -------------------------------------------------------------------------------- 1 | setupSubresources( 10 | 'domains', 11 | 'ip_access_control_lists', 12 | 'credential_lists' 13 | ); 14 | } 15 | 16 | public function getResourceName($camelized = false) { 17 | return "SIP"; 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /vendor/twilio/sdk/Services/Twilio/Rest/SmsMessage.php: -------------------------------------------------------------------------------- 1 | $from, 14 | 'To' => $to, 15 | 'Body' => $body 16 | ) + $params); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /vendor/twilio/sdk/Services/Twilio/Rest/Transcription.php: -------------------------------------------------------------------------------- 1 | setupSubresources( 7 | 'today', 8 | 'yesterday', 9 | 'all_time', 10 | 'this_month', 11 | 'last_month', 12 | 'daily', 13 | 'monthly', 14 | 'yearly' 15 | ); 16 | } 17 | } 18 | 19 | class Services_Twilio_Rest_Today extends Services_Twilio_TimeRangeResource { } 20 | 21 | class Services_Twilio_Rest_Yesterday extends Services_Twilio_TimeRangeResource { } 22 | 23 | class Services_Twilio_Rest_LastMonth extends Services_Twilio_TimeRangeResource { } 24 | 25 | class Services_Twilio_Rest_ThisMonth extends Services_Twilio_TimeRangeResource { } 26 | 27 | class Services_Twilio_Rest_AllTime extends Services_Twilio_TimeRangeResource { } 28 | 29 | class Services_Twilio_Rest_Daily extends Services_Twilio_UsageResource { } 30 | 31 | class Services_Twilio_Rest_Monthly extends Services_Twilio_UsageResource { } 32 | 33 | class Services_Twilio_Rest_Yearly extends Services_Twilio_UsageResource { } 34 | -------------------------------------------------------------------------------- /vendor/twilio/sdk/Services/Twilio/Rest/UsageTrigger.php: -------------------------------------------------------------------------------- 1 | `_. 13 | * @param string $value Fire the trigger when usage crosses this value. 14 | * @param string $url The URL to request when the trigger fires. 15 | * @param array $params Optional parameters for this trigger. A full list of parameters can be found in the `Usage Trigger documentation `_. 16 | * @return Services_Twilio_Rest_UsageTrigger The created trigger 17 | */ 18 | function create($category, $value, $url, array $params = array()) { 19 | return parent::_create(array( 20 | 'UsageCategory' => $category, 21 | 'TriggerValue' => $value, 22 | 'CallbackUrl' => $url, 23 | ) + $params); 24 | } 25 | 26 | } 27 | 28 | -------------------------------------------------------------------------------- /vendor/twilio/sdk/Services/Twilio/RestException.php: -------------------------------------------------------------------------------- 1 | status = $status; 27 | $this->info = $info; 28 | parent::__construct($message, $code); 29 | } 30 | 31 | /** 32 | * Get the HTTP status code 33 | */ 34 | public function getStatus() { 35 | return $this->status; 36 | } 37 | 38 | /** 39 | * Get a link to more information 40 | */ 41 | public function getInfo() { 42 | return $this->info; 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /vendor/twilio/sdk/Services/Twilio/SIPListResource.php: -------------------------------------------------------------------------------- 1 | 6 | * @license http://creativecommons.org/licenses/MIT/ MIT 7 | * @link http://pear.php.net/package/Services_Twilio 8 | */ 9 | class Services_Twilio_TimeRangeResource extends Services_Twilio_UsageResource { 10 | 11 | /** 12 | * Return a UsageRecord corresponding to the given category. 13 | * 14 | * @param string $category The category of usage to retrieve. For a full 15 | * list of valid categories, please see the documentation at 16 | * http://www.twilio.com/docs/api/rest/usage-records#usage-all-categories 17 | * @return Services_Twilio_Rest_UsageRecord 18 | * @throws Services_Twilio_RestException 19 | */ 20 | public function getCategory($category) { 21 | $page = $this->getPage(0, 1, array( 22 | 'Category' => $category, 23 | )); 24 | $items = $page->getItems(); 25 | if (!is_array($items) || count($items) === 0) { 26 | throw new Services_Twilio_RestException( 27 | 400, "Usage record data is unformattable."); 28 | } 29 | return $items[0]; 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /vendor/twilio/sdk/Services/Twilio/TinyHttp.php: -------------------------------------------------------------------------------- 1 | array( 27 | * CURLOPT_USERAGENT => self::USER_AGENT, 28 | * CURLOPT_HTTPHEADER => array('Accept-Charset: utf-8'), 29 | * CURLOPT_CAINFO => dirname(__FILE__) . '/cacert.pem', 30 | * )) 31 | * ); 32 | */ 33 | class Services_Twilio_TinyHttp { 34 | var $user, $pass, $scheme, $host, $port, $debug, $curlopts; 35 | 36 | public function __construct($uri = '', $kwargs = array()) { 37 | foreach (parse_url($uri) as $name => $value) $this->$name = $value; 38 | $this->debug = isset($kwargs['debug']) ? !!$kwargs['debug'] : NULL; 39 | $this->curlopts = isset($kwargs['curlopts']) ? $kwargs['curlopts'] : array(); 40 | } 41 | 42 | public function __call($name, $args) { 43 | list($res, $req_headers, $req_body) = $args + array(0, array(), ''); 44 | 45 | $opts = $this->curlopts + array( 46 | CURLOPT_URL => "$this->scheme://$this->host$res", 47 | CURLOPT_HEADER => TRUE, 48 | CURLOPT_RETURNTRANSFER => TRUE, 49 | CURLOPT_INFILESIZE => -1, 50 | CURLOPT_POSTFIELDS => NULL, 51 | CURLOPT_TIMEOUT => 60, 52 | ); 53 | 54 | foreach ($req_headers as $k => $v) $opts[CURLOPT_HTTPHEADER][] = "$k: $v"; 55 | if ($this->port) $opts[CURLOPT_PORT] = $this->port; 56 | if ($this->debug) $opts[CURLINFO_HEADER_OUT] = TRUE; 57 | if ($this->user && $this->pass) $opts[CURLOPT_USERPWD] = "$this->user:$this->pass"; 58 | switch ($name) { 59 | case 'get': 60 | $opts[CURLOPT_HTTPGET] = TRUE; 61 | break; 62 | case 'post': 63 | $opts[CURLOPT_POST] = TRUE; 64 | $opts[CURLOPT_POSTFIELDS] = $req_body; 65 | break; 66 | case 'put': 67 | $opts[CURLOPT_PUT] = TRUE; 68 | if (strlen($req_body)) { 69 | if ($buf = fopen('php://memory', 'w+')) { 70 | fwrite($buf, $req_body); 71 | fseek($buf, 0); 72 | $opts[CURLOPT_INFILE] = $buf; 73 | $opts[CURLOPT_INFILESIZE] = strlen($req_body); 74 | } else throw new Services_Twilio_TinyHttpException('unable to open temporary file'); 75 | } 76 | break; 77 | case 'head': 78 | $opts[CURLOPT_NOBODY] = TRUE; 79 | break; 80 | default: 81 | $opts[CURLOPT_CUSTOMREQUEST] = strtoupper($name); 82 | break; 83 | } 84 | try { 85 | if ($curl = curl_init()) { 86 | if (curl_setopt_array($curl, $opts)) { 87 | if ($response = curl_exec($curl)) { 88 | $parts = explode("\r\n\r\n", $response, 3); 89 | list($head, $body) = ($parts[0] == 'HTTP/1.1 100 Continue') 90 | ? array($parts[1], $parts[2]) 91 | : array($parts[0], $parts[1]); 92 | $status = curl_getinfo($curl, CURLINFO_HTTP_CODE); 93 | if ($this->debug) { 94 | error_log( 95 | curl_getinfo($curl, CURLINFO_HEADER_OUT) . 96 | $req_body 97 | ); 98 | } 99 | $header_lines = explode("\r\n", $head); 100 | array_shift($header_lines); 101 | foreach ($header_lines as $line) { 102 | list($key, $value) = explode(":", $line, 2); 103 | $headers[$key] = trim($value); 104 | } 105 | curl_close($curl); 106 | if (isset($buf) && is_resource($buf)) { 107 | fclose($buf); 108 | } 109 | return array($status, $headers, $body); 110 | } else { 111 | throw new Services_Twilio_TinyHttpException(curl_error($curl)); 112 | } 113 | } else throw new Services_Twilio_TinyHttpException(curl_error($curl)); 114 | } else throw new Services_Twilio_TinyHttpException('unable to initialize cURL'); 115 | } catch (ErrorException $e) { 116 | if (is_resource($curl)) curl_close($curl); 117 | if (isset($buf) && is_resource($buf)) fclose($buf); 118 | throw $e; 119 | } 120 | } 121 | 122 | public function authenticate($user, $pass) { 123 | $this->user = $user; 124 | $this->pass = $pass; 125 | } 126 | } 127 | -------------------------------------------------------------------------------- /vendor/twilio/sdk/Services/Twilio/Twiml.php: -------------------------------------------------------------------------------- 1 | 12 | * License: http://creativecommons.org/licenses/MIT/ MIT 13 | */ 14 | class Services_Twilio_Twiml { 15 | 16 | protected $element; 17 | 18 | /** 19 | * Constructs a Twiml response. 20 | * 21 | * :param SimpleXmlElement|array $arg: Can be any of 22 | * 23 | * - the element to wrap 24 | * - attributes to add to the element 25 | * - if null, initialize an empty element named 'Response' 26 | */ 27 | public function __construct($arg = null) { 28 | switch (true) { 29 | case $arg instanceof SimpleXmlElement: 30 | $this->element = $arg; 31 | break; 32 | case $arg === null: 33 | $this->element = new SimpleXmlElement(''); 34 | break; 35 | case is_array($arg): 36 | $this->element = new SimpleXmlElement(''); 37 | foreach ($arg as $name => $value) { 38 | $this->element->addAttribute($name, $value); 39 | } 40 | break; 41 | default: 42 | throw new TwimlException('Invalid argument'); 43 | } 44 | } 45 | 46 | /** 47 | * Converts method calls into Twiml verbs. 48 | * 49 | * A basic example: 50 | * 51 | * .. code-block:: php 52 | * 53 | * php> print $this->say('hello'); 54 | * hello 55 | * 56 | * An example with attributes: 57 | * 58 | * .. code-block:: php 59 | * 60 | * print $this->say('hello', array('voice' => 'woman')); 61 | * hello 62 | * 63 | * You could even just pass in an attributes array, omitting the noun: 64 | * 65 | * .. code-block:: php 66 | * 67 | * print $this->gather(array('timeout' => '20')); 68 | * 69 | * 70 | * :param string $verb: The Twiml verb. 71 | * :param array $args: 72 | * - (noun string) 73 | * - (noun string, attributes array) 74 | * - (attributes array) 75 | * 76 | * :return: A SimpleXmlElement 77 | * :rtype: SimpleXmlElement 78 | */ 79 | public function __call($verb, array $args) 80 | { 81 | list($noun, $attrs) = $args + array('', array()); 82 | if (is_array($noun)) { 83 | list($attrs, $noun) = array($noun, ''); 84 | } 85 | /* addChild does not escape XML, while addAttribute does. This means if 86 | * you pass unescaped ampersands ("&") to addChild, you will generate 87 | * an error. 88 | * 89 | * Some inexperienced developers will pass in unescaped ampersands, and 90 | * we want to make their code work, by escaping the ampersands for them 91 | * before passing the string to addChild. (with htmlentities) 92 | * 93 | * However other people will know what to do, and their code 94 | * already escapes ampersands before passing them to addChild. We don't 95 | * want to break their existing code by turning their &'s into 96 | * &amp; 97 | * 98 | * We also want to use numeric entities, not named entities so that we 99 | * are fully compatible with XML 100 | * 101 | * The following lines accomplish the desired behavior. 102 | */ 103 | $decoded = html_entity_decode($noun, ENT_COMPAT, 'UTF-8'); 104 | $normalized = htmlspecialchars($decoded, ENT_COMPAT, 'UTF-8', false); 105 | $child = empty($noun) 106 | ? $this->element->addChild(ucfirst($verb)) 107 | : $this->element->addChild(ucfirst($verb), $normalized); 108 | foreach ($attrs as $name => $value) { 109 | /* Note that addAttribute escapes raw ampersands by default, so we 110 | * haven't touched its implementation. So this is the matrix for 111 | * addAttribute: 112 | * 113 | * & turns into & 114 | * & turns into &amp; 115 | */ 116 | if (is_bool($value)) { 117 | $value = ($value === true) ? 'true' : 'false'; 118 | } 119 | $child->addAttribute($name, $value); 120 | } 121 | return new static($child); 122 | } 123 | 124 | /** 125 | * Returns the object as XML. 126 | * 127 | * :return: The response as an XML string 128 | * :rtype: string 129 | */ 130 | public function __toString() 131 | { 132 | $xml = $this->element->asXml(); 133 | return str_replace( 134 | '', 135 | '', $xml); 136 | } 137 | } 138 | -------------------------------------------------------------------------------- /vendor/twilio/sdk/Services/Twilio/UsageResource.php: -------------------------------------------------------------------------------- 1 | 6 | * @license http://creativecommons.org/licenses/MIT/ MIT 7 | * @link http://pear.php.net/package/Services_Twilio 8 | */ 9 | class Services_Twilio_UsageResource extends Services_Twilio_ListResource { 10 | public function getResourceName($camelized = false) { 11 | $this->instance_name = 'Services_Twilio_Rest_UsageRecord'; 12 | return $camelized ? 'UsageRecords' : 'usage_records'; 13 | } 14 | 15 | public function __construct($client, $uri) { 16 | $uri = preg_replace("#UsageRecords#", "Usage/Records", $uri); 17 | parent::__construct($client, $uri); 18 | } 19 | } 20 | 21 | -------------------------------------------------------------------------------- /vendor/twilio/sdk/composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "twilio/sdk", 3 | "type": "library", 4 | "description": "A PHP wrapper for Twilio's API", 5 | "keywords": ["twilio", "sms", "api"], 6 | "homepage": "http://github.com/twilio/twilio-php", 7 | "license": "MIT", 8 | "authors": [ 9 | { 10 | "name": "Kevin Burke", 11 | "email": "kevin@twilio.com" 12 | }, 13 | { 14 | "name": "Kyle Conroy", 15 | "email": "kyle+pear@twilio.com" 16 | } 17 | ], 18 | "require": { 19 | "php": ">=5.2.1" 20 | }, 21 | "require-dev": { 22 | "mockery/mockery": ">=0.7.2", 23 | "phpunit/phpunit": "3.7.*" 24 | }, 25 | "autoload": { 26 | "psr-0": { 27 | "Services_Twilio": "" 28 | } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /vendor/twilio/sdk/docs/Makefile: -------------------------------------------------------------------------------- 1 | # Makefile for Sphinx documentation 2 | # 3 | 4 | # You can set these variables from the command line. 5 | SPHINXOPTS = 6 | SPHINXBUILD = sphinx-build 7 | PAPER = 8 | BUILDDIR = _build 9 | 10 | # Internal variables. 11 | PAPEROPT_a4 = -D latex_paper_size=a4 12 | PAPEROPT_letter = -D latex_paper_size=letter 13 | ALLSPHINXOPTS = -d $(BUILDDIR)/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) . 14 | 15 | .PHONY: help clean html dirhtml singlehtml pickle json htmlhelp qthelp devhelp epub latex latexpdf text man changes linkcheck doctest 16 | 17 | help: 18 | @echo "Please use \`make ' where is one of" 19 | @echo " html to make standalone HTML files" 20 | @echo " dirhtml to make HTML files named index.html in directories" 21 | @echo " singlehtml to make a single large HTML file" 22 | @echo " pickle to make pickle files" 23 | @echo " json to make JSON files" 24 | @echo " htmlhelp to make HTML files and a HTML help project" 25 | @echo " qthelp to make HTML files and a qthelp project" 26 | @echo " devhelp to make HTML files and a Devhelp project" 27 | @echo " epub to make an epub" 28 | @echo " latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter" 29 | @echo " latexpdf to make LaTeX files and run them through pdflatex" 30 | @echo " text to make text files" 31 | @echo " man to make manual pages" 32 | @echo " changes to make an overview of all changed/added/deprecated items" 33 | @echo " linkcheck to check all external links for integrity" 34 | @echo " doctest to run all doctests embedded in the documentation (if enabled)" 35 | 36 | clean: 37 | -rm -rf $(BUILDDIR)/* 38 | 39 | html: 40 | $(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html 41 | @echo 42 | @echo "Build finished. The HTML pages are in $(BUILDDIR)/html." 43 | 44 | dirhtml: 45 | $(SPHINXBUILD) -b dirhtml $(ALLSPHINXOPTS) $(BUILDDIR)/dirhtml 46 | @echo 47 | @echo "Build finished. The HTML pages are in $(BUILDDIR)/dirhtml." 48 | 49 | singlehtml: 50 | $(SPHINXBUILD) -b singlehtml $(ALLSPHINXOPTS) $(BUILDDIR)/singlehtml 51 | @echo 52 | @echo "Build finished. The HTML page is in $(BUILDDIR)/singlehtml." 53 | 54 | pickle: 55 | $(SPHINXBUILD) -b pickle $(ALLSPHINXOPTS) $(BUILDDIR)/pickle 56 | @echo 57 | @echo "Build finished; now you can process the pickle files." 58 | 59 | json: 60 | $(SPHINXBUILD) -b json $(ALLSPHINXOPTS) $(BUILDDIR)/json 61 | @echo 62 | @echo "Build finished; now you can process the JSON files." 63 | 64 | htmlhelp: 65 | $(SPHINXBUILD) -b htmlhelp $(ALLSPHINXOPTS) $(BUILDDIR)/htmlhelp 66 | @echo 67 | @echo "Build finished; now you can run HTML Help Workshop with the" \ 68 | ".hhp project file in $(BUILDDIR)/htmlhelp." 69 | 70 | qthelp: 71 | $(SPHINXBUILD) -b qthelp $(ALLSPHINXOPTS) $(BUILDDIR)/qthelp 72 | @echo 73 | @echo "Build finished; now you can run "qcollectiongenerator" with the" \ 74 | ".qhcp project file in $(BUILDDIR)/qthelp, like this:" 75 | @echo "# qcollectiongenerator $(BUILDDIR)/qthelp/Services_Twilio.qhcp" 76 | @echo "To view the help file:" 77 | @echo "# assistant -collectionFile $(BUILDDIR)/qthelp/Services_Twilio.qhc" 78 | 79 | devhelp: 80 | $(SPHINXBUILD) -b devhelp $(ALLSPHINXOPTS) $(BUILDDIR)/devhelp 81 | @echo 82 | @echo "Build finished." 83 | @echo "To view the help file:" 84 | @echo "# mkdir -p $$HOME/.local/share/devhelp/Services_Twilio" 85 | @echo "# ln -s $(BUILDDIR)/devhelp $$HOME/.local/share/devhelp/Services_Twilio" 86 | @echo "# devhelp" 87 | 88 | epub: 89 | $(SPHINXBUILD) -b epub $(ALLSPHINXOPTS) $(BUILDDIR)/epub 90 | @echo 91 | @echo "Build finished. The epub file is in $(BUILDDIR)/epub." 92 | 93 | latex: 94 | $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex 95 | @echo 96 | @echo "Build finished; the LaTeX files are in $(BUILDDIR)/latex." 97 | @echo "Run \`make' in that directory to run these through (pdf)latex" \ 98 | "(use \`make latexpdf' here to do that automatically)." 99 | 100 | latexpdf: 101 | $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex 102 | @echo "Running LaTeX files through pdflatex..." 103 | make -C $(BUILDDIR)/latex all-pdf 104 | @echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex." 105 | 106 | text: 107 | $(SPHINXBUILD) -b text $(ALLSPHINXOPTS) $(BUILDDIR)/text 108 | @echo 109 | @echo "Build finished. The text files are in $(BUILDDIR)/text." 110 | 111 | man: 112 | $(SPHINXBUILD) -b man $(ALLSPHINXOPTS) $(BUILDDIR)/man 113 | @echo 114 | @echo "Build finished. The manual pages are in $(BUILDDIR)/man." 115 | 116 | changes: 117 | $(SPHINXBUILD) -b changes $(ALLSPHINXOPTS) $(BUILDDIR)/changes 118 | @echo 119 | @echo "The overview file is in $(BUILDDIR)/changes." 120 | 121 | linkcheck: 122 | $(SPHINXBUILD) -b linkcheck $(ALLSPHINXOPTS) $(BUILDDIR)/linkcheck 123 | @echo 124 | @echo "Link check complete; look for any errors in the above output " \ 125 | "or in $(BUILDDIR)/linkcheck/output.txt." 126 | 127 | doctest: 128 | $(SPHINXBUILD) -b doctest $(ALLSPHINXOPTS) $(BUILDDIR)/doctest 129 | @echo "Testing of doctests in the sources finished, look at the " \ 130 | "results in $(BUILDDIR)/doctest/output.txt." 131 | -------------------------------------------------------------------------------- /vendor/twilio/sdk/docs/_themes/.gitignore: -------------------------------------------------------------------------------- 1 | *.pyc 2 | *.pyo 3 | .DS_Store 4 | -------------------------------------------------------------------------------- /vendor/twilio/sdk/docs/_themes/LICENSE: -------------------------------------------------------------------------------- 1 | Modifications: 2 | 3 | Copyright (c) 2011 Kenneth Reitz. 4 | 5 | 6 | Original Project: 7 | 8 | Copyright (c) 2010 by Armin Ronacher. 9 | 10 | 11 | Some rights reserved. 12 | 13 | Redistribution and use in source and binary forms of the theme, with or 14 | without modification, are permitted provided that the following conditions 15 | are met: 16 | 17 | * Redistributions of source code must retain the above copyright 18 | notice, this list of conditions and the following disclaimer. 19 | 20 | * Redistributions in binary form must reproduce the above 21 | copyright notice, this list of conditions and the following 22 | disclaimer in the documentation and/or other materials provided 23 | with the distribution. 24 | 25 | * The names of the contributors may not be used to endorse or 26 | promote products derived from this software without specific 27 | prior written permission. 28 | 29 | We kindly ask you to only use these themes in an unmodified manner just 30 | for Flask and Flask-related products, not for unrelated projects. If you 31 | like the visual style and want to use it for your own projects, please 32 | consider making some larger changes to the themes (such as changing 33 | font faces, sizes, colors or margins). 34 | 35 | THIS THEME IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 36 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 37 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 38 | ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 39 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 40 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 41 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 42 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 43 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 44 | ARISING IN ANY WAY OUT OF THE USE OF THIS THEME, EVEN IF ADVISED OF THE 45 | POSSIBILITY OF SUCH DAMAGE. 46 | -------------------------------------------------------------------------------- /vendor/twilio/sdk/docs/_themes/README.rst: -------------------------------------------------------------------------------- 1 | krTheme Sphinx Style 2 | ==================== 3 | 4 | This repository contains sphinx styles Kenneth Reitz uses in most of 5 | his projects. It is a drivative of Mitsuhiko's themes for Flask and Flask related 6 | projects. To use this style in your Sphinx documentation, follow 7 | this guide: 8 | 9 | 1. put this folder as _themes into your docs folder. Alternatively 10 | you can also use git submodules to check out the contents there. 11 | 12 | 2. add this to your conf.py: :: 13 | 14 | sys.path.append(os.path.abspath('_themes')) 15 | html_theme_path = ['_themes'] 16 | html_theme = 'flask' 17 | 18 | The following themes exist: 19 | 20 | **kr** 21 | the standard flask documentation theme for large projects 22 | 23 | **kr_small** 24 | small one-page theme. Intended to be used by very small addon libraries. 25 | 26 | -------------------------------------------------------------------------------- /vendor/twilio/sdk/docs/_themes/flask_theme_support.py: -------------------------------------------------------------------------------- 1 | # flasky extensions. flasky pygments style based on tango style 2 | from pygments.style import Style 3 | from pygments.token import Keyword, Name, Comment, String, Error, \ 4 | Number, Operator, Generic, Whitespace, Punctuation, Other, Literal 5 | 6 | 7 | class FlaskyStyle(Style): 8 | background_color = "#f8f8f8" 9 | default_style = "" 10 | 11 | styles = { 12 | # No corresponding class for the following: 13 | #Text: "", # class: '' 14 | Whitespace: "underline #f8f8f8", # class: 'w' 15 | Error: "#a40000 border:#ef2929", # class: 'err' 16 | Other: "#000000", # class 'x' 17 | 18 | Comment: "italic #8f5902", # class: 'c' 19 | Comment.Preproc: "noitalic", # class: 'cp' 20 | 21 | Keyword: "bold #004461", # class: 'k' 22 | Keyword.Constant: "bold #004461", # class: 'kc' 23 | Keyword.Declaration: "bold #004461", # class: 'kd' 24 | Keyword.Namespace: "bold #004461", # class: 'kn' 25 | Keyword.Pseudo: "bold #004461", # class: 'kp' 26 | Keyword.Reserved: "bold #004461", # class: 'kr' 27 | Keyword.Type: "bold #004461", # class: 'kt' 28 | 29 | Operator: "#582800", # class: 'o' 30 | Operator.Word: "bold #004461", # class: 'ow' - like keywords 31 | 32 | Punctuation: "bold #000000", # class: 'p' 33 | 34 | # because special names such as Name.Class, Name.Function, etc. 35 | # are not recognized as such later in the parsing, we choose them 36 | # to look the same as ordinary variables. 37 | Name: "#000000", # class: 'n' 38 | Name.Attribute: "#c4a000", # class: 'na' - to be revised 39 | Name.Builtin: "#004461", # class: 'nb' 40 | Name.Builtin.Pseudo: "#3465a4", # class: 'bp' 41 | Name.Class: "#000000", # class: 'nc' - to be revised 42 | Name.Constant: "#000000", # class: 'no' - to be revised 43 | Name.Decorator: "#888", # class: 'nd' - to be revised 44 | Name.Entity: "#ce5c00", # class: 'ni' 45 | Name.Exception: "bold #cc0000", # class: 'ne' 46 | Name.Function: "#000000", # class: 'nf' 47 | Name.Property: "#000000", # class: 'py' 48 | Name.Label: "#f57900", # class: 'nl' 49 | Name.Namespace: "#000000", # class: 'nn' - to be revised 50 | Name.Other: "#000000", # class: 'nx' 51 | Name.Tag: "bold #004461", # class: 'nt' - like a keyword 52 | Name.Variable: "#000000", # class: 'nv' - to be revised 53 | Name.Variable.Class: "#000000", # class: 'vc' - to be revised 54 | Name.Variable.Global: "#000000", # class: 'vg' - to be revised 55 | Name.Variable.Instance: "#000000", # class: 'vi' - to be revised 56 | 57 | Number: "#990000", # class: 'm' 58 | 59 | Literal: "#000000", # class: 'l' 60 | Literal.Date: "#000000", # class: 'ld' 61 | 62 | String: "#4e9a06", # class: 's' 63 | String.Backtick: "#4e9a06", # class: 'sb' 64 | String.Char: "#4e9a06", # class: 'sc' 65 | String.Doc: "italic #8f5902", # class: 'sd' - like a comment 66 | String.Double: "#4e9a06", # class: 's2' 67 | String.Escape: "#4e9a06", # class: 'se' 68 | String.Heredoc: "#4e9a06", # class: 'sh' 69 | String.Interpol: "#4e9a06", # class: 'si' 70 | String.Other: "#4e9a06", # class: 'sx' 71 | String.Regex: "#4e9a06", # class: 'sr' 72 | String.Single: "#4e9a06", # class: 's1' 73 | String.Symbol: "#4e9a06", # class: 'ss' 74 | 75 | Generic: "#000000", # class: 'g' 76 | Generic.Deleted: "#a40000", # class: 'gd' 77 | Generic.Emph: "italic #000000", # class: 'ge' 78 | Generic.Error: "#ef2929", # class: 'gr' 79 | Generic.Heading: "bold #000080", # class: 'gh' 80 | Generic.Inserted: "#00A000", # class: 'gi' 81 | Generic.Output: "#888", # class: 'go' 82 | Generic.Prompt: "#745334", # class: 'gp' 83 | Generic.Strong: "bold #000000", # class: 'gs' 84 | Generic.Subheading: "bold #800080", # class: 'gu' 85 | Generic.Traceback: "bold #a40000", # class: 'gt' 86 | } 87 | -------------------------------------------------------------------------------- /vendor/twilio/sdk/docs/_themes/kr/layout.html: -------------------------------------------------------------------------------- 1 | {%- extends "basic/layout.html" %} 2 | {%- block extrahead %} 3 | {{ super() }} 4 | {% if theme_touch_icon %} 5 | 6 | {% endif %} 7 | 9 | {% endblock %} 10 | {%- block relbar2 %}{% endblock %} 11 | {%- block footer %} 12 | 15 | 28 | 29 | Fork me on GitHub 30 | 31 | 32 | {%- endblock %} 33 | -------------------------------------------------------------------------------- /vendor/twilio/sdk/docs/_themes/kr/relations.html: -------------------------------------------------------------------------------- 1 |

Related Topics

2 | 20 | -------------------------------------------------------------------------------- /vendor/twilio/sdk/docs/_themes/kr/static/small_flask.css: -------------------------------------------------------------------------------- 1 | /* 2 | * small_flask.css_t 3 | * ~~~~~~~~~~~~~~~~~ 4 | * 5 | * :copyright: Copyright 2010 by Armin Ronacher. 6 | * :license: Flask Design License, see LICENSE for details. 7 | */ 8 | 9 | body { 10 | margin: 0; 11 | padding: 20px 30px; 12 | } 13 | 14 | div.documentwrapper { 15 | float: none; 16 | background: white; 17 | } 18 | 19 | div.sphinxsidebar { 20 | display: block; 21 | float: none; 22 | width: 102.5%; 23 | margin: 50px -30px -20px -30px; 24 | padding: 10px 20px; 25 | background: #333; 26 | color: white; 27 | } 28 | 29 | div.sphinxsidebar h3, div.sphinxsidebar h4, div.sphinxsidebar p, 30 | div.sphinxsidebar h3 a { 31 | color: white; 32 | } 33 | 34 | div.sphinxsidebar a { 35 | color: #aaa; 36 | } 37 | 38 | div.sphinxsidebar p.logo { 39 | display: none; 40 | } 41 | 42 | div.document { 43 | width: 100%; 44 | margin: 0; 45 | } 46 | 47 | div.related { 48 | display: block; 49 | margin: 0; 50 | padding: 10px 0 20px 0; 51 | } 52 | 53 | div.related ul, 54 | div.related ul li { 55 | margin: 0; 56 | padding: 0; 57 | } 58 | 59 | div.footer { 60 | display: none; 61 | } 62 | 63 | div.bodywrapper { 64 | margin: 0; 65 | } 66 | 67 | div.body { 68 | min-height: 0; 69 | padding: 0; 70 | } 71 | -------------------------------------------------------------------------------- /vendor/twilio/sdk/docs/_themes/kr/theme.conf: -------------------------------------------------------------------------------- 1 | [theme] 2 | inherit = basic 3 | stylesheet = flasky.css 4 | pygments_style = flask_theme_support.FlaskyStyle 5 | 6 | [options] 7 | touch_icon = 8 | -------------------------------------------------------------------------------- /vendor/twilio/sdk/docs/_themes/kr_small/layout.html: -------------------------------------------------------------------------------- 1 | {% extends "basic/layout.html" %} 2 | {% block header %} 3 | {{ super() }} 4 | {% if pagename == 'index' %} 5 |
6 | {% endif %} 7 | {% endblock %} 8 | {% block footer %} 9 | {% if pagename == 'index' %} 10 |
11 | {% endif %} 12 | {% endblock %} 13 | {# do not display relbars #} 14 | {% block relbar1 %}{% endblock %} 15 | {% block relbar2 %} 16 | {% if theme_github_fork %} 17 | Fork me on GitHub 19 | {% endif %} 20 | {% endblock %} 21 | {% block sidebar1 %}{% endblock %} 22 | {% block sidebar2 %}{% endblock %} 23 | -------------------------------------------------------------------------------- /vendor/twilio/sdk/docs/_themes/kr_small/theme.conf: -------------------------------------------------------------------------------- 1 | [theme] 2 | inherit = basic 3 | stylesheet = flasky.css 4 | nosidebar = true 5 | pygments_style = flask_theme_support.FlaskyStyle 6 | 7 | [options] 8 | index_logo = '' 9 | index_logo_height = 120px 10 | github_fork = '' 11 | -------------------------------------------------------------------------------- /vendor/twilio/sdk/docs/api/services.rst: -------------------------------------------------------------------------------- 1 | ############################### 2 | HTTP Helper Classes 3 | ############################### 4 | 5 | ********************** 6 | The Twilio Rest Client 7 | ********************** 8 | 9 | .. phpautoclass:: Services_Twilio 10 | :filename: ../Services/Twilio.php 11 | :members: 12 | 13 | *************************** 14 | Twilio's Custom HTTP Client 15 | *************************** 16 | 17 | .. phpautoclass:: Services_Twilio_TinyHttp 18 | :filename: ../Services/Twilio/TinyHttp.php 19 | :members: 20 | 21 | *********************** 22 | Twilio Rest Exceptions 23 | *********************** 24 | .. phpautoclass:: Services_Twilio_RestException 25 | :filename: ../Services/Twilio/RestException.php 26 | :members: 27 | -------------------------------------------------------------------------------- /vendor/twilio/sdk/docs/api/twiml.rst: -------------------------------------------------------------------------------- 1 | ########################################### 2 | API for TwiML Generation 3 | ########################################### 4 | 5 | .. phpautoclass:: Services_Twilio_Twiml 6 | :filename: ../Services/Twilio/Twiml.php 7 | :members: 8 | -------------------------------------------------------------------------------- /vendor/twilio/sdk/docs/index.rst: -------------------------------------------------------------------------------- 1 | .. Services_Twilio documentation master file, created by 2 | sphinx-quickstart on Tue Mar 8 04:02:01 2011. 3 | You can adapt this file completely to your liking, but it should at least 4 | contain the root `toctree` directive. 5 | 6 | ================= 7 | **twilio-php** 8 | ================= 9 | 10 | Status 11 | ======= 12 | 13 | This documentation is for version 3.12.5 of `twilio-php 14 | `_. 15 | 16 | Quickstart 17 | ============ 18 | 19 | Send an SMS 20 | >>>>>>>>>>> 21 | 22 | .. code-block:: php 23 | 24 | // Download the library and copy into the folder containing this file. 25 | require('/path/to/twilio-php/Services/Twilio.php'); 26 | 27 | $account_sid = "ACXXXXXX"; // Your Twilio account sid 28 | $auth_token = "YYYYYY"; // Your Twilio auth token 29 | 30 | $client = new Services_Twilio($account_sid, $auth_token); 31 | $message = $client->account->messages->sendMessage( 32 | '+14085551234', // From a Twilio number in your account 33 | '+12125551234', // Text any number 34 | "Hello monkey!" 35 | ); 36 | 37 | print $message->sid; 38 | 39 | Make a Call 40 | >>>>>>>>>>>>>> 41 | 42 | .. code-block:: php 43 | 44 | // Download the library and copy into the folder containing this file. 45 | require('/path/to/twilio-php/Services/Twilio.php'); 46 | 47 | $account_sid = "ACXXXXXX"; // Your Twilio account sid 48 | $auth_token = "YYYYYY"; // Your Twilio auth token 49 | 50 | $client = new Services_Twilio($account_sid, $auth_token); 51 | $call = $client->account->calls->create( 52 | '+14085551234', // From a Twilio number in your account 53 | '+12125551234', // Call any number 54 | 55 | // Read TwiML at this URL when a call connects (hold music) 56 | 'http://twimlets.com/holdmusic?Bucket=com.twilio.music.ambient' 57 | ); 58 | 59 | Generating TwiML 60 | >>>>>>>>>>>>>>>> 61 | 62 | To control phone calls, your application needs to output `TwiML 63 | `_. Use :class:`Services_Twilio_Twiml` 64 | to easily create such responses. 65 | 66 | .. code-block:: php 67 | 68 | $response = new Services_Twilio_Twiml(); 69 | $response->say('Hello'); 70 | $response->play('https://api.twilio.com/cowbell.mp3', array("loop" => 5)); 71 | print $response; 72 | 73 | .. code-block:: xml 74 | 75 | 76 | 77 | Hello 78 | https://api.twilio.com/cowbell.mp3 79 | 80 | 81 | View more examples of TwiML generation here: :ref:`usage-twiml` 82 | 83 | Installation 84 | ============ 85 | 86 | There are two ways to install **twilio-php**: via the PEAR installer, or by 87 | downloading the source. 88 | 89 | Via PEAR 90 | >>>>>>>>>>>>> 91 | 92 | Use the ``Makefile`` in the repo's top 93 | 94 | .. code-block:: bash 95 | 96 | pear channel-discover twilio.github.com/pear 97 | pear install twilio/Services_Twilio 98 | 99 | From Source 100 | >>>>>>>>>>>>> 101 | 102 | If you aren't using PEAR, download the `source (.zip) 103 | `_, which includes all the 104 | dependencies. 105 | 106 | User Guide 107 | ================== 108 | 109 | REST API 110 | >>>>>>>>>> 111 | 112 | .. toctree:: 113 | :maxdepth: 2 114 | :glob: 115 | 116 | usage/rest 117 | usage/rest/* 118 | 119 | TwiML and other utilities 120 | >>>>>>>>>>>>>>>>>>>>>>>>>> 121 | 122 | .. toctree:: 123 | :maxdepth: 1 124 | 125 | usage/twiml 126 | usage/validation 127 | usage/token-generation 128 | faq/ 129 | 130 | API Documentation 131 | ================== 132 | 133 | .. toctree:: 134 | :maxdepth: 3 135 | :glob: 136 | 137 | api/* 138 | 139 | 140 | Support and Development 141 | =========================== 142 | 143 | All development occurs on `Github `_. To 144 | check out the source, run 145 | 146 | .. code-block:: bash 147 | 148 | git clone git@github.com:twilio/twilio-php.git 149 | 150 | Report bugs using the Github `issue tracker `_. 151 | 152 | If you've got questions that aren't answered by this documentation, ask the 153 | Twilio support team at help@twilio.com. 154 | 155 | Running the Tests 156 | >>>>>>>>>>>>>>>>>>>>>>>>> 157 | 158 | The unit tests depend on `Mockery `_ and 159 | `PHPUnit `_. First, 'discover' all 160 | the necessary `PEAR` channels: 161 | 162 | .. code-block:: bash 163 | 164 | make test-install 165 | 166 | After installation, run the tests with :data:`make`. 167 | 168 | .. code-block:: bash 169 | 170 | make test 171 | 172 | 173 | Making the Documentation 174 | >>>>>>>>>>>>>>>>>>>>>>>>>> 175 | 176 | Our documentation is written using `Sphinx `_. You'll 177 | need to install Sphinx and the Sphinx PHP domain before you can build the docs. 178 | 179 | .. code-block:: bash 180 | 181 | make docs-install 182 | 183 | Once you have those installed, making the docs is easy. 184 | 185 | .. code-block:: bash 186 | 187 | make docs 188 | 189 | -------------------------------------------------------------------------------- /vendor/twilio/sdk/docs/quickstart.rst: -------------------------------------------------------------------------------- 1 | ============= 2 | Quickstart 3 | ============= 4 | 5 | Making a Call 6 | ============== 7 | 8 | .. code-block:: php 9 | 10 | $sid = "ACXXXXXX"; // Your Twilio account sid 11 | $token = "YYYYYY"; // Your Twilio auth token 12 | 13 | $client = new Services_Twilio($sid, $token); 14 | $call = $client->account->calls->create( 15 | '9991231234', // From this number 16 | '8881231234', // Call this number 17 | 'http://foo.com/call.xml' 18 | ); 19 | 20 | Generating TwiML 21 | ================== 22 | 23 | To control phone calls, your application need to output TwiML. Use :class:`Services_Twilio_Twiml` to easily create such responses. 24 | 25 | .. code-block:: php 26 | 27 | $response = new Services_Twilio_Twiml(); 28 | $response->say('Hello'); 29 | print $response; 30 | 31 | .. code-block:: xml 32 | 33 | 34 | monkey.mp3 35 | -------------------------------------------------------------------------------- /vendor/twilio/sdk/docs/requirements.txt: -------------------------------------------------------------------------------- 1 | sphinxcontrib-phpdomain 2 | hg+https://bitbucket.org/tk0miya/tk.phpautodoc 3 | 4 | -------------------------------------------------------------------------------- /vendor/twilio/sdk/docs/usage/rest.rst: -------------------------------------------------------------------------------- 1 | .. _ref-rest: 2 | 3 | ========================== 4 | Using the Twilio REST API 5 | ========================== 6 | 7 | Since version 3.0, we've introduced an updated API for interacting with the 8 | Twilio REST API. Gone are the days of manual URL creation and XML parsing. 9 | 10 | Creating a REST Client 11 | ======================= 12 | 13 | Before querying the API, you'll need to create a :php:class:`Services_Twilio` 14 | instance. The constructor takes your Twilio Account Sid and Auth 15 | Token (both available through your `Twilio Account Dashboard 16 | `_). 17 | 18 | .. code-block:: php 19 | 20 | $ACCOUNT_SID = "AC123"; 21 | $AUTH_TOKEN = "secret"; 22 | $client = new Services_Twilio($ACCOUNT_SID, $AUTH_TOKEN); 23 | 24 | The :attr:`account` attribute 25 | ----------------------------- 26 | 27 | You access the Twilio API resources through this :attr:`$client`, 28 | specifically the :attr:`$account` attribute, which is an instance of 29 | :php:class:`Services_Twilio_Rest_Account`. We'll use the `Calls resource 30 | `_ as an example. 31 | 32 | Listing Resources 33 | ==================== 34 | 35 | Iterating over the :attr:`calls` attribute will iterate over all of your call 36 | records, handling paging for you. Only use this when you need to get all your 37 | records. 38 | 39 | The :attr:`$call` object is a :php:class:`Services_Twilio_Rest_Call`, which 40 | means you can easily access fields through it's properties. The attribute names 41 | are lowercase and use underscores for sepearators. All the available attributes 42 | are documented in the :doc:`/api/rest` documentation. 43 | 44 | .. code-block:: php 45 | 46 | // If you have many calls, this could take a while 47 | foreach($client->account->calls as $call) { 48 | print $call->price . '\n'; 49 | print $call->duration . '\n'; 50 | } 51 | 52 | Filtering Resources 53 | ------------------- 54 | 55 | Many Twilio list resources allow for filtering via :php:meth:`getIterator` 56 | which takes an optional array of filter parameters. These parameters correspond 57 | directlty to the listed query string parameters in the REST API documentation. 58 | 59 | You can create a filtered iterator like this: 60 | 61 | .. code-block:: php 62 | 63 | $filteredCalls = $client->account->calls->getIterator( 64 | 0, 50, array("Status" => "in-progress")); 65 | foreach($filteredCalls as $call) { 66 | print $call->price . '\n'; 67 | print $call->duration . '\n'; 68 | } 69 | 70 | Retrieving the Total Number of Resources 71 | ---------------------------------------- 72 | 73 | Each of the list resources supports the `Countable` interface, which means you 74 | can retrieve the total number of list items like so: 75 | 76 | .. code-block:: php 77 | 78 | echo count($client->account->calls); 79 | 80 | Getting a Specific Resource 81 | ============================= 82 | 83 | If you know the unique identifier for a resource, you can get that resource 84 | using the :php:meth:`get` method on the list resource. 85 | 86 | .. code-block:: php 87 | 88 | $call = $client->account->calls->get("CA123"); 89 | 90 | :php:meth:`get` fetches objects lazily, so it will only load a resource when it 91 | is needed. This allows you to get nested objects without making multiple HTTP 92 | requests. 93 | 94 | .. code-block:: php 95 | 96 | $participant = $client->account->conferences 97 | ->get("CO123")->participants->get("PF123"); 98 | 99 | -------------------------------------------------------------------------------- /vendor/twilio/sdk/docs/usage/rest/accounts.rst: -------------------------------------------------------------------------------- 1 | ================== 2 | Accounts 3 | ================== 4 | 5 | Updating Account Information 6 | ============================== 7 | 8 | Updating :class:`Account ` information is really easy: 9 | 10 | .. code-block:: php 11 | 12 | $client = new Services_Twilio('AC123', '123'); 13 | $account = $client->account; 14 | $account->update(array('FriendlyName' => 'My Awesome Account')); 15 | 16 | Creating a Subaccount 17 | ============================== 18 | 19 | .. code-block:: php 20 | 21 | $client = new Services_Twilio('AC123', '123'); 22 | $subaccount = $client->accounts->create(array( 23 | 'FriendlyName' => 'My Awesome SubAccount' 24 | )); 25 | -------------------------------------------------------------------------------- /vendor/twilio/sdk/docs/usage/rest/applications.rst: -------------------------------------------------------------------------------- 1 | ================== 2 | Applications 3 | ================== 4 | 5 | Creating Applications 6 | ============================== 7 | 8 | .. code-block:: php 9 | 10 | $client = new Services_Twilio('AC123', '123'); 11 | $application = $client->account->applications->create('Application Friendly Name', 12 | array( 13 | 'FriendlyName' => 'My Application Name', 14 | 'VoiceUrl' => 'http://foo.com/voice/url', 15 | 'VoiceFallbackUrl' => 'http://foo.com/voice/fallback/url', 16 | 'VoiceMethod' => 'POST', 17 | 'SmsUrl' => 'http://foo.com/sms/url', 18 | 'SmsFallbackUrl' => 'http://foo.com/sms/fallback/url', 19 | 'SmsMethod' => 'POST' 20 | ) 21 | ); 22 | 23 | 24 | Updating An Application 25 | ============================== 26 | 27 | .. code-block:: php 28 | 29 | $client = new Services_Twilio('AC123', '123'); 30 | $application = $client->account->applications->get('AP123'); 31 | $application->update(array( 32 | 'VoiceUrl' => 'http://foo.com/new/voice/url' 33 | )); 34 | 35 | 36 | Finding an Application by Name 37 | ============================== 38 | 39 | Find an :class:`Application` by its name (full name match). 40 | 41 | .. code-block:: php 42 | 43 | $client = new Services_Twilio('AC123', '123'); 44 | $application = false; 45 | $params = array( 46 | 'FriendlyName' => 'My Application Name' 47 | ); 48 | foreach($client->account->applications->getIterator(0, 1, $params) as $_application) { 49 | $application = $_application; 50 | } -------------------------------------------------------------------------------- /vendor/twilio/sdk/docs/usage/rest/callerids.rst: -------------------------------------------------------------------------------- 1 | ============ 2 | Caller Ids 3 | ============ 4 | 5 | Validate a Phone Number 6 | ======================= 7 | Adding a new phone number to your validated numbers is quick and easy: 8 | 9 | .. code-block:: php 10 | 11 | $client = new Services_Twilio('AC123', '123'); 12 | $response = $client->account->outgoing_caller_ids->create('+15554441234'); 13 | print $response->validation_code; 14 | 15 | Twilio will call the provided number and for the validation code to be entered. 16 | 17 | Listing all Validated Phone Numbers 18 | =================================== 19 | 20 | Show all the current caller_ids: 21 | 22 | .. code-block:: php 23 | 24 | $client = new Services_Twilio('AC123', '123'); 25 | foreach ($client->account->outgoing_caller_ids as $caller_id) { 26 | print $caller_id->friendly_name; 27 | } 28 | -------------------------------------------------------------------------------- /vendor/twilio/sdk/docs/usage/rest/calls.rst: -------------------------------------------------------------------------------- 1 | ============= 2 | Phone Calls 3 | ============= 4 | 5 | Making a Phone Call 6 | =================== 7 | 8 | The :class:`Calls` resource allows you to make outgoing calls: 9 | 10 | .. code-block:: php 11 | 12 | $client = new Services_Twilio('AC123', '123'); 13 | $call = $client->account->calls->create( 14 | '9991231234', // From this number 15 | '8881231234', // Call this number 16 | 'http://foo.com/call.xml' 17 | ); 18 | print $call->length; 19 | print $call->sid; 20 | 21 | Adding Extra Call Parameters 22 | ============================ 23 | 24 | Add extra parameters, like a `StatusCallback` when the call ends, like this: 25 | 26 | .. code-block:: php 27 | 28 | $client = new Services_Twilio('AC123', '123'); 29 | $call = $client->account->calls->create( 30 | '9991231234', // From this number 31 | '8881231234', // Call this number 32 | 'http://foo.com/call.xml', 33 | array( 34 | 'StatusCallback' => 'http://foo.com/callback', 35 | 'StatusCallbackMethod' => 'GET' 36 | ) 37 | ); 38 | 39 | A full list of extra parameters can be found `here 40 | `_. 41 | 42 | Listing Calls 43 | ============= 44 | 45 | It's easy to iterate over your list of calls. 46 | 47 | .. code-block:: php 48 | 49 | $client = new Services_Twilio('AC123', '123'); 50 | foreach ($client->account->calls as $call) { 51 | echo "From: {$call->from}\nTo: {$call->to}\nSid: {$call->sid}\n\n"; 52 | } 53 | 54 | Filtering Calls 55 | ====================== 56 | 57 | Let's say you want to find all of the calls that have been sent from 58 | a particular number. You can do so by constructing an iterator explicitly: 59 | 60 | .. code-block:: php 61 | 62 | $client = new Services_Twilio('AC123', '123'); 63 | foreach ($client->account->calls->getIterator(0, 50, array( 64 | 'From' => '+14105551234' 65 | )) as $call) { 66 | echo "From: {$call->from}\nTo: {$call->to}\nSid: {$call->sid}\n\n"; 67 | } 68 | 69 | Accessing Resources from a Specific Call 70 | ======================================== 71 | 72 | The :class:`Call` resource has some subresources you can access, such as 73 | notifications and recordings. If you have already have a :class:`Call` 74 | resource, they are easy to get: 75 | 76 | .. code-block:: php 77 | 78 | $client = new Services_Twilio('AC123', '123'); 79 | foreach ($client->account->calls as $call) { 80 | $notifications = $call->notifications; 81 | if (is_array($notifications)) { 82 | foreach ($notifications as $notification) { 83 | print $notification->sid; 84 | } 85 | } 86 | 87 | $transcriptions = $call->transcriptions; 88 | if (is_array($transcriptions)) { 89 | foreach ($transcriptions as $transcription) { 90 | print $transcription->sid; 91 | } 92 | } 93 | 94 | $recordings = $call->recordings; 95 | if (is_array($recordings)) { 96 | foreach ($recordings as $recording) { 97 | print $recording->sid; 98 | } 99 | } 100 | } 101 | 102 | Be careful, as the above code makes quite a few HTTP requests and may display 103 | PHP warnings for unintialized variables. 104 | 105 | Retrieve a Call Record 106 | ====================== 107 | 108 | If you already have a :class:`Call` sid, you can use the client to retrieve 109 | that record.: 110 | 111 | .. code-block:: php 112 | 113 | $client = new Services_Twilio('AC123', '123'); 114 | $sid = "CA12341234" 115 | $call = $client->account->calls->get($sid) 116 | 117 | Modifying live calls 118 | ==================== 119 | 120 | The :class:`Call` resource makes it easy to find current live calls and 121 | redirect them as necessary: 122 | 123 | .. code-block:: php 124 | 125 | $client = new Services_Twilio('AC123', '123'); 126 | $calls = $client->account->calls->getIterator(0, 50, array('Status' => 'in-progress')); 127 | foreach ($calls as $call) { 128 | $call->update(array('Url' => 'http://foo.com/new.xml', 'Method' => 'POST')); 129 | } 130 | 131 | Ending all live calls is also possible: 132 | 133 | .. code-block:: php 134 | 135 | $client = new Services_Twilio('AC123', '123'); 136 | $calls = $client->account->calls->getIterator(0, 50, array('Status' => 'in-progress')); 137 | foreach ($calls as $call) { 138 | $call->hangup(); 139 | } 140 | 141 | Note that :meth:`hangup` will also cancel calls currently queued. 142 | -------------------------------------------------------------------------------- /vendor/twilio/sdk/docs/usage/rest/conferences.rst: -------------------------------------------------------------------------------- 1 | ============= 2 | Conferences 3 | ============= 4 | 5 | List All Conferences 6 | ==================== 7 | 8 | .. code-block:: php 9 | 10 | $client = new Services_Twilio('AC123', '123'); 11 | foreach ($client->account->conferences as $conference) { 12 | print $conference->friendly_name; 13 | } 14 | 15 | For a full list of properties available on a conference, as well as a full list 16 | of ways to filter a conference, please see the `Conference API Documentation 17 | `_ on our website. 18 | 19 | Filter Conferences by Status 20 | ============================ 21 | 22 | .. code-block:: php 23 | 24 | $client = new Services_Twilio('AC123', '123'); 25 | foreach ($client->account->conferences->getIterator(0, 50, array( 26 | 'Status' => 'in-progress' 27 | )) as $conf) { 28 | print $conf->sid; 29 | } 30 | 31 | Mute all participants 32 | ===================== 33 | 34 | At the moment, using an iterator directly will cause this method to infinitely 35 | loop. Instead, use the getPage function. As conferences are limited to 40 36 | participants, getPage(0, 50) should return a list of every participant in 37 | a conference. 38 | 39 | .. code-block:: php 40 | 41 | $sid = "CO119231312"; 42 | $client = new Services_Twilio('AC123', '123'); 43 | $conference = $client->account->conferences->get($sid); 44 | $page = $conference->participants->getPage(0, 50); 45 | $participants = $page->participants; 46 | foreach ($participants as $p) { 47 | $p->mute(); 48 | } 49 | -------------------------------------------------------------------------------- /vendor/twilio/sdk/docs/usage/rest/members.rst: -------------------------------------------------------------------------------- 1 | ============= 2 | Members 3 | ============= 4 | 5 | List All Members in a Queue 6 | ============================ 7 | 8 | Each queue instance resource has a list of members. 9 | 10 | .. code-block:: php 11 | 12 | $client = new Services_Twilio('AC123', '123'); 13 | $queue_sid = 'QQ123'; 14 | $queue = $client->account->queues->get('QQ123'); 15 | foreach ($queue->members as $member) { 16 | echo "Call Sid: {$member->call_sid}\nWait Time: {$member->wait_time}\n"; 17 | } 18 | 19 | Dequeue a Member 20 | ================= 21 | 22 | .. code-block:: php 23 | 24 | $client = new Services_Twilio('AC123', '123'); 25 | $queue = $client->account->queues->get('QQ123'); 26 | foreach ($queue->members as $member) { 27 | // Dequeue the first member and fetch the Forward twimlet for that 28 | // member. 29 | $member->dequeue('http://twimlets.com/forward', 'GET'); 30 | break; 31 | } 32 | 33 | Retrieve the Member at the Front of a Queue 34 | =========================================== 35 | 36 | The Members class has a method called ``front`` which can be used to retrieve 37 | the member at the front of the queue. 38 | 39 | .. code-block:: php 40 | 41 | $client = new Services_Twilio('AC123', '123'); 42 | $queue = $client->account->queues->get('QQ123'); 43 | $firstMember = $queue->members->front(); 44 | echo $firstMember->position; 45 | echo $firstMember->call_sid; 46 | 47 | -------------------------------------------------------------------------------- /vendor/twilio/sdk/docs/usage/rest/messages.rst: -------------------------------------------------------------------------------- 1 | ============= 2 | Messages 3 | ============= 4 | 5 | Sending a Message 6 | ===================== 7 | 8 | The :class:`Messages ` resource allows you to 9 | send outgoing SMS or MMS messages. 10 | 11 | .. code-block:: php 12 | 13 | require('/path/to/twilio-php/Services/Twilio.php'); 14 | 15 | $client = new Services_Twilio('AC123', '123'); 16 | $message = $client->account->messages->sendMessage( 17 | '+14085551234', // From a Twilio number in your account 18 | '+12125551234', // Text any number 19 | 'Hello monkey!', // Message body (if any) 20 | array('http://example.com/image.jpg'), // An array of MediaUrls 21 | ); 22 | 23 | echo $message->sid; 24 | 25 | Listing Messages 26 | ==================== 27 | 28 | It's easy to iterate over your messages. 29 | 30 | .. code-block:: php 31 | 32 | $client = new Services_Twilio('AC123', '123'); 33 | foreach ($client->account->messages as $message) { 34 | echo "From: {$message->from}\nTo: {$message->to}\nBody: " . $message->body; 35 | } 36 | 37 | Filtering Messages 38 | ====================== 39 | 40 | Let's say you want to find all of the messages that have been sent from 41 | a particular number. You can do so by constructing an iterator explicitly: 42 | 43 | .. code-block:: php 44 | 45 | $client = new Services_Twilio('AC123', '123'); 46 | foreach ($client->account->messages->getIterator(0, 50, array( 47 | 'From' => '+14105551234', 48 | )) as $message) { 49 | echo "From: {$message->from}\nTo: {$message->to}\nBody: " . $message->body; 50 | } 51 | -------------------------------------------------------------------------------- /vendor/twilio/sdk/docs/usage/rest/notifications.rst: -------------------------------------------------------------------------------- 1 | =============== 2 | Notifications 3 | =============== 4 | 5 | Filter Notifications by Log Level 6 | ================================= 7 | 8 | .. code-block:: php 9 | 10 | $client = new Services_Twilio('AC123', '123'); 11 | foreach ($client->account->notifications->getIterator(0, 50, array("LogLevel" => 0)) as $n) { 12 | print $n->error_code; 13 | } 14 | -------------------------------------------------------------------------------- /vendor/twilio/sdk/docs/usage/rest/queues.rst: -------------------------------------------------------------------------------- 1 | ============= 2 | Queues 3 | ============= 4 | 5 | Create a New Queue 6 | ===================== 7 | 8 | To create a new queue, make an HTTP POST request to the Queues resource. 9 | 10 | .. code-block:: php 11 | 12 | require('/path/to/twilio-php/Services/Twilio.php'); 13 | 14 | $client = new Services_Twilio('AC123', '123'); 15 | // Default MaxSize is 100. Or change it by adding a parameter, like so 16 | $queue = $client->account->queues->create('First Queue', 17 | array('MaxSize' => 10)); 18 | 19 | print $queue->sid; 20 | print $queue->friendly_name; 21 | 22 | Listing Queues 23 | ==================== 24 | 25 | It's easy to iterate over your list of queues. 26 | 27 | .. code-block:: php 28 | 29 | $client = new Services_Twilio('AC123', '123'); 30 | foreach ($client->account->queues as $queue) { 31 | echo $queue->sid; 32 | } 33 | 34 | Deleting Queues 35 | ==================== 36 | 37 | .. code-block:: php 38 | 39 | $client = new Services_Twilio('AC123', '123'); 40 | $queue_sid = 'QQ123'; 41 | $client->account->queues->delete('QQ123'); 42 | 43 | Retrieve the Member at the Front of a Queue 44 | =========================================== 45 | 46 | The Members class has a method called ``front`` which can be used to retrieve 47 | the member at the front of the queue. 48 | 49 | .. code-block:: php 50 | 51 | $client = new Services_Twilio('AC123', '123'); 52 | $queue = $client->account->queues->get('QQ123'); 53 | $firstMember = $queue->members->front(); 54 | echo $firstMember->position; 55 | echo $firstMember->call_sid; 56 | 57 | -------------------------------------------------------------------------------- /vendor/twilio/sdk/docs/usage/rest/recordings.rst: -------------------------------------------------------------------------------- 1 | ========== 2 | Recordings 3 | ========== 4 | 5 | Listing Recordings 6 | ------------------ 7 | 8 | Run the following to get a list of all of your recordings: 9 | 10 | .. code-block:: php 11 | 12 | $accountSid = 'AC1234567890abcdef1234567890a'; 13 | $authToken = 'abcdef1234567890abcdefabcde9'; 14 | $client = new Services_Twilio($accountSid, $authToken); 15 | 16 | foreach($client->account->recordings as $recording) { 17 | echo "Access recording {$recording->sid} at:" . "\n"; 18 | echo $recording->uri; 19 | } 20 | 21 | For more information about which properties are available for a recording 22 | object, please see the `Twilio Recordings API Documentation `_. 23 | 24 | Please note that the ``uri`` returned by default is a JSON dictionary 25 | containing metadata about the recording; you can access the .wav version by 26 | stripping the ``.json`` extension from the ``uri`` returned by the library. 27 | 28 | Filtering Recordings By Call Sid 29 | -------------------------------- 30 | 31 | Pass filters as an array to filter your list of recordings, with any of the 32 | filters listed in the `recording list documentation `_. 33 | 34 | .. code-block:: php 35 | 36 | $accountSid = 'AC1234567890abcdef1234567890a'; 37 | $authToken = 'abcdef1234567890abcdefabcde9'; 38 | $client = new Services_Twilio($accountSid, $authToken); 39 | 40 | foreach($client->account->recordings->getIterator(0, 50, array('DateCreated>' => '2011-01-01')) as $recording) { 41 | echo $recording->uri . "\n"; 42 | } 43 | 44 | Deleting a Recording 45 | -------------------- 46 | 47 | To delete a recording, get the sid of the recording, and then pass it to the 48 | client. 49 | 50 | .. code-block:: php 51 | 52 | $accountSid = 'AC1234567890abcdef1234567890a'; 53 | $authToken = 'abcdef1234567890abcdefabcde9'; 54 | $client = new Services_Twilio($accountSid, $authToken); 55 | 56 | foreach($client->account->recordings as $recording) { 57 | $client->account->recordings->delete($recording->sid); 58 | echo "Deleted recording {$recording->sid}, the first one in the list."; 59 | break; 60 | } 61 | 62 | -------------------------------------------------------------------------------- /vendor/twilio/sdk/docs/usage/rest/sip.rst: -------------------------------------------------------------------------------- 1 | ============= 2 | Sip In 3 | ============= 4 | 5 | Getting started with Sip 6 | ========================== 7 | 8 | If you're unfamiliar with SIP, please see the `SIP API Documentation 9 | `_ on our website. 10 | 11 | Creating a Sip Domain 12 | ========================= 13 | 14 | The :class:`Domains ` resource allows you to 15 | create a new domain. To create a new domain, you'll need to choose a unique 16 | domain that lives under sip.twilio.com. For example, doug.sip.twilio.com. 17 | 18 | .. code-block:: php 19 | 20 | require('/path/to/twilio-php/Services/Twilio.php'); 21 | 22 | $client = new Services_Twilio('AC123', '123'); 23 | $domain = $client->account->sip->domains->create( 24 | "Doug's Domain", // The FriendlyName for your new domain 25 | "doug.sip.twilio.com", // The sip domain for your new domain 26 | array( 27 | 'VoiceUrl' => 'http://example.com/voice', 28 | )); 29 | 30 | echo $domain->sid; 31 | 32 | Creating a new IpAccessControlList 33 | ==================================== 34 | 35 | To control access to your new domain, you'll need to explicitly grant access 36 | to individual ip addresses. To do this, you'll first need to create an 37 | :class:`IpAccessControlList ` to hold 38 | the ip addresses you wish to allow. 39 | 40 | .. code-block:: php 41 | 42 | require('/path/to/twilio-php/Services/Twilio.php'); 43 | 44 | $client = new Services_Twilio('AC123', '123'); 45 | $ip_access_control_list = $client->account->sip->ip_access_control_lists->create( 46 | "Doug's IpAccessControlList", // The FriendlyName for your new ip access control list 47 | ); 48 | 49 | echo $ip_access_control_list->sid; 50 | 51 | Adding an IpAddress to an IpAccessControlList 52 | ============================================== 53 | 54 | Now it's time to add an :class:`IpAddress 55 | ` to your new :class:`IpAccessControlList 56 | `. 57 | 58 | .. code-block:: php 59 | 60 | require('/path/to/twilio-php/Services/Twilio.php'); 61 | 62 | $client = new Services_Twilio('AC123', '123'); 63 | $ip_address = $client->account->sip->ip_access_control_lists->get('AC123')->ip_addresses->create( 64 | "Doug's IpAddress", // The FriendlyName for this IpAddress 65 | '127.0.0.1', // The ip address for this IpAddress 66 | ); 67 | 68 | echo $ip_address->sid; 69 | 70 | Adding an IpAccessControlList to a Domain 71 | =========================================== 72 | 73 | Once you've created a :class:`Domain ` and an 74 | :class:`IpAccessControlList ` 75 | you need to associate them. To do this, 76 | create an :class:`IpAccessControlListMapping 77 | `. 78 | 79 | .. code-block:: php 80 | 81 | require('/path/to/twilio-php/Services/Twilio.php'); 82 | 83 | $client = new Services_Twilio('AC123', '123'); 84 | $ip_access_control_list_mapping = $client->account->sip->domains->get('SD123')->ip_access_control_list_mappings->create( 85 | 'AL123', // The sid of your IpAccessControlList 86 | ); 87 | 88 | echo $ip_access_control_list_mapping->sid; 89 | -------------------------------------------------------------------------------- /vendor/twilio/sdk/docs/usage/rest/sms-messages.rst: -------------------------------------------------------------------------------- 1 | ============= 2 | SMS Messages 3 | ============= 4 | 5 | Sending a SMS Message 6 | ===================== 7 | 8 | 9 | The :php:class:`Services_Twilio_Rest_SmsMessages` resource allows you to send 10 | outgoing text messages. 11 | 12 | .. code-block:: php 13 | 14 | require('/path/to/twilio-php/Services/Twilio.php'); 15 | 16 | $client = new Services_Twilio('AC123', '123'); 17 | $message = $client->account->sms_messages->create( 18 | '+14085551234', // From a Twilio number in your account 19 | '+12125551234', // Text any number 20 | "Hello monkey!" 21 | ); 22 | 23 | print $message->sid; 24 | 25 | Listing SMS Messages 26 | ==================== 27 | 28 | It's easy to iterate over your SMS messages. 29 | 30 | .. code-block:: php 31 | 32 | $client = new Services_Twilio('AC123', '123'); 33 | foreach ($client->account->sms_messages as $message) { 34 | echo "From: {$message->from}\nTo: {$message->to}\nBody: " . $message->body; 35 | } 36 | 37 | Filtering SMS Messages 38 | ====================== 39 | 40 | Let's say you want to find all of the SMS messages that have been sent from 41 | a particular number. You can do so by constructing an iterator explicitly: 42 | 43 | .. code-block:: php 44 | 45 | $client = new Services_Twilio('AC123', '123'); 46 | foreach ($client->account->sms_messages->getIterator(0, 50, array( 47 | 'From' => '+14105551234', 48 | )) as $message) { 49 | echo "From: {$message->from}\nTo: {$message->to}\nBody: " . $message->body; 50 | } 51 | -------------------------------------------------------------------------------- /vendor/twilio/sdk/docs/usage/rest/transcriptions.rst: -------------------------------------------------------------------------------- 1 | ================ 2 | Transcriptions 3 | ================ 4 | 5 | Show all Transcribed Messages 6 | ============================= 7 | 8 | .. code-block:: php 9 | 10 | $client = new Services_Twilio('AC123', '123'); 11 | foreach ($client->account->transcriptions as $t) { 12 | print $t->transcription_text; 13 | } 14 | -------------------------------------------------------------------------------- /vendor/twilio/sdk/docs/usage/rest/usage-records.rst: -------------------------------------------------------------------------------- 1 | ============= 2 | Usage Records 3 | ============= 4 | 5 | Twilio offers a Usage Record API so you can better measure how much you've been 6 | using Twilio. Here are some examples of how you can use PHP to access the usage 7 | API. 8 | 9 | Retrieve All Usage Records 10 | ========================== 11 | 12 | .. code-block:: php 13 | 14 | $client = new Services_Twilio('AC123', '456bef'); 15 | foreach ($client->account->usage_records as $record) { 16 | echo "Record: $record"; 17 | } 18 | 19 | Retrieve Usage Records For A Time Interval 20 | ========================================== 21 | 22 | UsageRecords support `several convenience subresources 23 | `_ that 24 | can be accessed as properties on the `record` object. 25 | 26 | .. code-block:: php 27 | 28 | $client = new Services_Twilio('AC123', '456bef'); 29 | foreach ($client->account->usage_records->last_month as $record) { 30 | echo "Record: $record"; 31 | } 32 | 33 | Retrieve All Time Usage for A Usage Category 34 | ============================================ 35 | 36 | By default, Twilio will return your all-time usage for a given usage category. 37 | 38 | .. code-block:: php 39 | 40 | $client = new Services_Twilio('AC123', '456bef'); 41 | $callRecord = $client->account->usage_records->getCategory('calls'); 42 | echo $callRecord->usage; 43 | 44 | Retrieve All Usage for a Given Time Period 45 | ========================================== 46 | 47 | You can filter your UsageRecord list by providing `StartDate` and `EndDate` 48 | parameters. 49 | 50 | .. code-block:: php 51 | 52 | $client = new Services_Twilio('AC123', '456bef'); 53 | foreach ($client->account->usage_records->getIterator(0, 50, array( 54 | 'StartDate' => '2012-08-01', 55 | 'EndDate' => '2012-08-31', 56 | )) as $record) { 57 | echo $record->description . "\n"; 58 | echo $record->usage . "\n"; 59 | } 60 | 61 | Retrieve Today's SMS Usage 62 | ========================== 63 | 64 | You can use the `today` record subresource, and then retrieve the record 65 | directly with the `getCategory` function. 66 | 67 | .. code-block:: php 68 | 69 | $client = new Services_Twilio('AC123', '456bef'); 70 | // You can substitute 'yesterday', 'all_time' for 'today' below 71 | $smsRecord = $client->account->usage_records->today->getCategory('sms'); 72 | echo $smsRecord->usage; 73 | 74 | Retrieve Daily Usage Over a One-Month Period 75 | ============================================= 76 | 77 | The code below will retrieve daily summaries of recordings usage for August 78 | 2012. To retrieve all categories of usage, remove the 'Category' filter from 79 | the `getIterator` array. 80 | 81 | .. code-block:: php 82 | 83 | $client = new Services_Twilio('AC123', '456bef'); 84 | foreach ($client->account->usage_records->daily->getIterator(0, 50, array( 85 | 'StartDate' => '2012-08-01', 86 | 'EndDate' => '2012-08-31', 87 | 'Category' => 'recordings', 88 | )) as $record) { 89 | echo $record->usage; 90 | } 91 | 92 | -------------------------------------------------------------------------------- /vendor/twilio/sdk/docs/usage/rest/usage-triggers.rst: -------------------------------------------------------------------------------- 1 | ============== 2 | Usage Triggers 3 | ============== 4 | 5 | Twilio offers a Usage Trigger API so you can get notifications when your Twilio 6 | usage exceeds a given level. Here are some examples of how you can 7 | use PHP to create new usage triggers or modify existing triggers. 8 | 9 | Retrieve A Usage Trigger's Properties 10 | ===================================== 11 | 12 | If you know the Sid of your usage trigger, retrieving it is easy. 13 | 14 | .. code-block:: php 15 | 16 | $client = new Services_Twilio('AC123', '456bef'); 17 | $usageSid = 'UT123'; 18 | $usageTrigger = $client->account->usage_triggers->get($usageSid); 19 | echo $usageTrigger->usage_category; 20 | 21 | Update Properties on a UsageTrigger 22 | =================================== 23 | 24 | .. code-block:: php 25 | 26 | $client = new Services_Twilio('AC123', '456bef'); 27 | $usageSid = 'UT123'; 28 | $usageTrigger = $client->account->usage_triggers->get($usageSid); 29 | $usageTrigger->update(array( 30 | 'FriendlyName' => 'New usage trigger friendly name', 31 | 'CallbackUrl' => 'http://example.com/new-trigger-url', 32 | )); 33 | 34 | Retrieve All Triggers 35 | ===================== 36 | 37 | .. code-block:: php 38 | 39 | $client = new Services_Twilio('AC123', '456bef'); 40 | foreach ($client->account->usage_triggers as $trigger) { 41 | echo "Category: {$trigger->usage_category}\nTriggerValue: {$trigger->trigger_value}\n"; 42 | } 43 | 44 | Filter Trigger List By Category 45 | =============================== 46 | 47 | Pass filters to the `getIterator` function to create a filtered list. 48 | 49 | .. code-block:: php 50 | 51 | $client = new Services_Twilio('AC123', '456bef'); 52 | foreach ($client->account->usage_triggers->getIterator( 53 | 0, 50, array( 54 | 'UsageCategory' => 'sms', 55 | )) as $trigger 56 | ) { 57 | echo "Value: " . $trigger->trigger_value . "\n"; 58 | } 59 | 60 | Create a New Trigger 61 | ==================== 62 | 63 | Pass a usage category, a value and a callback URL to the `create` method. 64 | 65 | .. code-block:: php 66 | 67 | $client = new Services_Twilio('AC123', '456bef'); 68 | $trigger = $client->account->usage_triggers->create( 69 | 'totalprice', 70 | '250.75', 71 | 'http://example.com/usage' 72 | ); 73 | 74 | Create a Recurring Trigger 75 | ========================== 76 | 77 | To have your trigger reset once every day, month, or year, pass the 78 | `Recurring` key as part of the params array. A list of optional 79 | trigger parameters can be found in the `Usage Triggers Documentation 80 | `_. 82 | 83 | .. code-block:: php 84 | 85 | $client = new Services_Twilio('AC123', '456bef'); 86 | $trigger = $client->account->usage_triggers->create( 87 | 'totalprice', 88 | '250.75', 89 | 'http://example.com/usage', 90 | array('Recurring' => 'monthly', 'TriggerBy' => 'price') 91 | ); 92 | 93 | -------------------------------------------------------------------------------- /vendor/twilio/sdk/docs/usage/token-generation.rst: -------------------------------------------------------------------------------- 1 | =========================== 2 | Generate Capability Tokens 3 | =========================== 4 | 5 | `Twilio Client `_ allows you to make and recieve connections in the browser. You can place a call to a phone on the PSTN network, all without leaving your browser. See the `Twilio Client Quickstart `_ to get up and running with Twilio Client. 6 | 7 | Capability tokens are used by `Twilio Client `_ to provide connection security and authorization. The `Capability Token documentation `_ explains indepth the purpose and features of these tokens. 8 | 9 | :php:class:`Services_Twilio_Capability` is responsible for the creation of these capability tokens. You'll need your Twilio AccountSid and AuthToken. 10 | 11 | .. code-block:: php 12 | 13 | require('/path/to/twilio-php/Services/Twilio/Capability.php'); 14 | 15 | $accountSid = "AC123123"; 16 | $authToken = "secret"; 17 | 18 | $capability = new Services_Twilio_Capability($accountSid, $authToken); 19 | 20 | 21 | Allow Incoming Connections 22 | ============================== 23 | 24 | Before a device running `Twilio Client `_ can recieve incoming connections, the instance must first register a name (such as "Alice" or "Bob"). The :php:meth:`allowCclientIncoming` method adds the client name to the capability token. 25 | 26 | .. code-block:: php 27 | 28 | $capability->allowClientIncoming("Alice"); 29 | 30 | 31 | Allow Outgoing Connections 32 | ============================== 33 | 34 | To make an outgoing connection from a `Twilio Client `_ device, you'll need to choose a `Twilio Application `_ to handle TwiML URLs. A Twilio Application is a collection of URLs responsible for outputing valid TwiML to control phone calls and SMS. 35 | 36 | .. code-block:: php 37 | 38 | $applicationSid = "AP123123"; // Twilio Application Sid 39 | $capability->allowClientOutgoing($applicationSid); 40 | 41 | :php:meth:`allowClientOutgoing` accepts an optional array of parameters. These parameters will be passed along when Twilio requests TwiML from the application. 42 | 43 | .. code-block:: php 44 | 45 | $applicationSid = "AP123123"; // Twilio Application Sid 46 | $params = array("Foo" => "Bar"); // Parameters to be passed 47 | $capability->allowClientOutgoing($applicationSid, $params); 48 | 49 | 50 | Generate a Token 51 | ================== 52 | 53 | .. code-block:: php 54 | 55 | $token = $capability->generateToken(); 56 | 57 | By default, this token will expire in one hour. If you'd like to change the token expiration time, :php:meth:`generateToken` takes an optional argument which specifies `time to live` in seconds. 58 | 59 | .. code-block:: php 60 | 61 | $token = $capability->generateToken(600); 62 | 63 | This token will now expire in 10 minutes. 64 | 65 | -------------------------------------------------------------------------------- /vendor/twilio/sdk/docs/usage/validation.rst: -------------------------------------------------------------------------------- 1 | =========================== 2 | Validate Incoming Requests 3 | =========================== 4 | 5 | Twilio requires that your TwiML-serving web server be open to the public. This is necessary so that Twilio can retrieve TwiML from urls and POST data back to your server. 6 | 7 | However, there may be people out there trying to spoof the Twilio service. Luckily, there's an easy way to validate that incoming requests are from Twilio and Twilio alone. 8 | 9 | An `indepth guide `_ to our security features can be found in our online documentation. 10 | 11 | Before you can validate requests, you'll need four pieces of information 12 | 13 | * your Twilio Auth Token 14 | * the POST data for the request 15 | * the requested URL 16 | * the X-Twilio-Signature header value 17 | 18 | Get your Auth Token from the `Twilio User Dashboard `_. 19 | 20 | Obtaining the other three pieces of information depends on the framework of your choosing. I will assume that you have the POST data as an array and the url and X-Twilio-Signature as strings. 21 | 22 | The below example will print out a confirmation message if the request is actually from Twilio.com 23 | 24 | .. code-block:: php 25 | 26 | // Your auth token from twilio.com/user/account 27 | $authToken = '12345'; 28 | 29 | // Download the twilio-php library from twilio.com/docs/php/install, include it 30 | // here 31 | require_once('/path/to/twilio-php/Services/Twilio.php'); 32 | $validator = new Services_Twilio_RequestValidator($authToken); 33 | 34 | // The Twilio request URL. You may be able to retrieve this from 35 | // $_SERVER['SCRIPT_URI'] 36 | $url = 'https://mycompany.com/myapp.php?foo=1&bar=2'; 37 | 38 | // The post variables in the Twilio request. You may be able to use 39 | // $postVars = $_POST 40 | $postVars = array( 41 | 'CallSid' => 'CA1234567890ABCDE', 42 | 'Caller' => '+14158675309', 43 | 'Digits' => '1234', 44 | 'From' => '+14158675309', 45 | 'To' => '+18005551212' 46 | ); 47 | 48 | // The X-Twilio-Signature header - in PHP this should be 49 | // $_SERVER["HTTP_X_TWILIO_SIGNATURE"]; 50 | $signature = 'RSOYDt4T1cUTdK1PDd93/VVr8B8='; 51 | 52 | if ($validator->validate($signature, $url, $postVars)) { 53 | echo "Confirmed to have come from Twilio."; 54 | } else { 55 | echo "NOT VALID. It might have been spoofed!"; 56 | } 57 | 58 | Trailing Slashes 59 | ================== 60 | 61 | If your URL uses an "index" page, such as index.php or index.html to handle the request, such as: https://mycompany.com/twilio where the real page is served from https://mycompany.com/twilio/index.php, then Apache or PHP may rewrite that URL a little bit so it's got a trailing slash... https://mycompany.com/twilio/ for example. 62 | 63 | Using the code above, or similar code in another language, you could end up with an incorrect hash because, Twilio built the hash using https://mycompany.com/twilio and you may have built the hash using https://mycompany.com/twilio/. 64 | 65 | 66 | 67 | -------------------------------------------------------------------------------- /vendor/twilio/sdk/package.php: -------------------------------------------------------------------------------- 1 | 29 | * @copyright 2014 Twilio 30 | * @license http://creativecommons.org/licenses/MIT/ 31 | * @link http://pear.php.net/package/Services_Twilio 32 | */ 33 | 34 | ini_set('display_errors', '0'); 35 | error_reporting(E_ALL & ~E_DEPRECATED & ~E_STRICT); 36 | require_once 'PEAR/PackageFileManager/File.php'; 37 | require_once 'PEAR/PackageFileManager2.php'; 38 | PEAR::setErrorHandling(PEAR_ERROR_DIE); 39 | 40 | $api_version = '3.12.5'; 41 | $api_state = 'stable'; 42 | 43 | $release_version = '3.12.5'; 44 | $release_state = 'stable'; 45 | $release_notes = 'Make SIP class PSR-0 compliant'; 46 | 47 | $description = <<setOptions( 55 | array( 56 | 'filelistgenerator' => 'file', 57 | 'simpleoutput' => true, 58 | 'baseinstalldir' => '/', 59 | 'packagedirectory' => './', 60 | 'dir_roles' => array( 61 | 'Services' => 'php', 62 | 'Services/Twilio' => 'php', 63 | 'tests' => 'test' 64 | ), 65 | 'ignore' => array( 66 | 'package.php', 67 | '*.tgz', 68 | 'scratch/*', 69 | 'vendor/*', 70 | 'composer.*', 71 | 'coverage/*', 72 | '.travis.yml', 73 | 'venv/*', 74 | ) 75 | ) 76 | ); 77 | 78 | $package->setPackage('Services_Twilio'); 79 | $package->setSummary('PHP helper library for Twilio'); 80 | $package->setDescription($description); 81 | $package->setChannel('twilio.github.com/pear'); 82 | $package->setPackageType('php'); 83 | $package->setLicense( 84 | 'MIT License', 85 | 'http://creativecommons.org/licenses/MIT/' 86 | ); 87 | 88 | $package->setNotes($release_notes); 89 | $package->setReleaseVersion($release_version); 90 | $package->setReleaseStability($release_state); 91 | $package->setAPIVersion($api_version); 92 | $package->setAPIStability($api_state); 93 | 94 | $package->addMaintainer( 95 | 'lead', 96 | 'ihumanable', 97 | 'Matt Nowack', 98 | 'matt@twilio.com' 99 | ); 100 | 101 | 102 | $package->setPhpDep('5.2.1'); 103 | 104 | $package->addPackageDepWithChannel('optional', 'Mockery', 'pear.survivethedeepend.com'); 105 | 106 | $package->setPearInstallerDep('1.9.3'); 107 | $package->generateContents(); 108 | $package->addRelease(); 109 | 110 | if (isset($_GET['make']) 111 | || (isset($_SERVER['argv']) && @$_SERVER['argv'][1] == 'make') 112 | ) { 113 | $package->writePackageFile(); 114 | } else { 115 | $package->debugPackageFile(); 116 | } 117 | 118 | -------------------------------------------------------------------------------- /vendor/twilio/sdk/tests/Bootstrap.php: -------------------------------------------------------------------------------- 1 | register(); 23 | 24 | require_once 'Twilio.php'; 25 | 26 | unset($root, $library, $tests, $path); 27 | 28 | -------------------------------------------------------------------------------- /vendor/twilio/sdk/tests/BuildQueryTest.php: -------------------------------------------------------------------------------- 1 | 'bar', 10 | 'baz' => 'bin', 11 | ); 12 | 13 | $this->assertEquals(Services_Twilio::buildQuery($data), 'foo=bar&baz=bin'); 14 | } 15 | 16 | public function testSameKey() { 17 | $data = array( 18 | 'foo' => array( 19 | 'bar', 20 | 'baz', 21 | 'bin', 22 | ), 23 | 'boo' => 'bah', 24 | ); 25 | 26 | $this->assertEquals(Services_Twilio::buildQuery($data), 27 | 'foo=bar&foo=baz&foo=bin&boo=bah'); 28 | } 29 | 30 | public function testKeylessData() { 31 | $data = array( 32 | 'bar', 33 | 'baz', 34 | 'bin', 35 | ); 36 | 37 | $this->assertEquals(Services_Twilio::buildQuery($data), '0=bar&1=baz&2=bin'); 38 | } 39 | 40 | public function testKeylessDataPrefix() { 41 | $data = array( 42 | 'bar', 43 | 'baz', 44 | 'bin', 45 | ); 46 | 47 | $this->assertEquals(Services_Twilio::buildQuery($data, 'var'), 'var0=bar&var1=baz&var2=bin'); 48 | } 49 | 50 | public function testQualifiedUserAgent() { 51 | $expected = Services_Twilio::USER_AGENT . " (php 5.4)"; 52 | $this->assertEquals(Services_Twilio::qualifiedUserAgent("5.4"), $expected); 53 | } 54 | 55 | } 56 | 57 | -------------------------------------------------------------------------------- /vendor/twilio/sdk/tests/CapabilityTest.php: -------------------------------------------------------------------------------- 1 | generateToken(), 'foo'); 10 | $this->assertEquals($payload->iss, "AC123"); 11 | $this->assertEquals($payload->scope, ''); 12 | } 13 | 14 | public function testInboundPermissions() { 15 | $token = new Services_Twilio_Capability('AC123', 'foo'); 16 | $token->allowClientIncoming("andy"); 17 | $payload = JWT::decode($token->generateToken(), 'foo'); 18 | 19 | $eurl = "scope:client:incoming?clientName=andy"; 20 | $this->assertEquals($payload->scope, $eurl); 21 | } 22 | 23 | public function testOutboundPermissions() { 24 | $token = new Services_Twilio_Capability('AC123', 'foo'); 25 | $token->allowClientOutgoing("AP123"); 26 | $payload = JWT::decode($token->generateToken(), 'foo');; 27 | $eurl = "scope:client:outgoing?appSid=AP123"; 28 | $this->assertContains($eurl, $payload->scope); 29 | } 30 | 31 | public function testOutboundPermissionsParams() { 32 | $token = new Services_Twilio_Capability('AC123', 'foo'); 33 | $token->allowClientOutgoing("AP123", array("foobar" => 3)); 34 | $payload = JWT::decode($token->generateToken(), 'foo'); 35 | 36 | $eurl = "scope:client:outgoing?appSid=AP123&appParams=foobar%3D3"; 37 | $this->assertEquals($payload->scope, $eurl); 38 | } 39 | 40 | public function testEvents() { 41 | $token = new Services_Twilio_Capability('AC123', 'foo'); 42 | $token->allowEventStream(); 43 | $payload = JWT::decode($token->generateToken(), 'foo'); 44 | 45 | $event_uri = "scope:stream:subscribe?path=%2F2010" 46 | . "-04-01%2FEvents¶ms="; 47 | $this->assertEquals($payload->scope, $event_uri); 48 | } 49 | 50 | public function testEventsWithFilters() { 51 | $token = new Services_Twilio_Capability('AC123', 'foo'); 52 | $token->allowEventStream(array("foobar" => "hey")); 53 | $payload = JWT::decode($token->generateToken(), 'foo'); 54 | 55 | $event_uri = "scope:stream:subscribe?path=%2F2010-" 56 | . "04-01%2FEvents¶ms=foobar%3Dhey"; 57 | $this->assertEquals($payload->scope, $event_uri); 58 | } 59 | 60 | 61 | public function testDecode() { 62 | $token = new Services_Twilio_Capability('AC123', 'foo'); 63 | $token->allowClientOutgoing("AP123", array("foobar"=> 3)); 64 | $token->allowClientIncoming("andy"); 65 | $token->allowEventStream(); 66 | 67 | $outgoing_uri = "scope:client:outgoing?appSid=" 68 | . "AP123&appParams=foobar%3D3&clientName=andy"; 69 | $incoming_uri = "scope:client:incoming?clientName=andy"; 70 | $event_uri = "scope:stream:subscribe?path=%2F2010-04-01%2FEvents"; 71 | 72 | $payload = JWT::decode($token->generateToken(), 'foo'); 73 | $scope = $payload->scope; 74 | 75 | $this->assertContains($outgoing_uri, $scope); 76 | $this->assertContains($incoming_uri, $scope); 77 | $this->assertContains($event_uri, $scope); 78 | } 79 | 80 | 81 | function testDecodeWithAuthToken() { 82 | try { 83 | $token = new Services_Twilio_Capability('AC123', 'foo'); 84 | $payload = JWT::decode($token->generateToken(), 'foo'); 85 | $this->assertSame($payload->iss, 'AC123'); 86 | } catch (UnexpectedValueException $e) { 87 | $this->assertTrue(false, "Could not decode with 'foo'"); 88 | } 89 | } 90 | 91 | function testClientNameValidation() { 92 | $this->setExpectedException('InvalidArgumentException'); 93 | $token = new Services_Twilio_Capability('AC123', 'foo'); 94 | $token->allowClientIncoming('@'); 95 | $this->fail('exception should have been raised'); 96 | } 97 | 98 | function zeroLengthNameInvalid() { 99 | $this->setExpectedException('InvalidArgumentException'); 100 | $token = new Services_Twilio_Capability('AC123', 'foo'); 101 | $token->allowClientIncoming(""); 102 | $this->fail('exception should have been raised'); 103 | } 104 | 105 | 106 | } 107 | -------------------------------------------------------------------------------- /vendor/twilio/sdk/tests/README: -------------------------------------------------------------------------------- 1 | # To run the tests, navigate to the twilio-php home directory, then run: 2 | 3 | make test 4 | -------------------------------------------------------------------------------- /vendor/twilio/sdk/tests/RequestValidatorTest.php: -------------------------------------------------------------------------------- 1 | "94612", 14 | "AccountSid" => "AC9a9f9392lad99kla0sklakjs90j092j3", 15 | "ApiVersion" => "2010-04-01", 16 | "CallSid" => "CAd800bb12c0426a7ea4230e492fef2a4f", 17 | "CallStatus" => "ringing", 18 | "Called" => "+15306384866", 19 | "CalledCity" => "OAKLAND", 20 | "CalledCountry" => "US", 21 | "CalledState" => "CA", 22 | "Caller" => "+15306666666", 23 | "CallerCity" => "SOUTH LAKE TAHOE", 24 | "CallerCountry" => "US", 25 | "CallerName" => "CA Wireless Call", 26 | "CallerState" => "CA", 27 | "CallerZip" => "89449", 28 | "Direction" => "inbound", 29 | "From" => "+15306666666", 30 | "FromCity" => "SOUTH LAKE TAHOE", 31 | "FromCountry" => "US", 32 | "FromState" => "CA", 33 | "FromZip" => "89449", 34 | "To" => "+15306384866", 35 | "ToCity" => "OAKLAND", 36 | "ToCountry" => "US", 37 | "ToState" => "CA", 38 | "ToZip" => "94612", 39 | ); 40 | 41 | $expected = "fF+xx6dTinOaCdZ0aIeNkHr/ZAA="; 42 | 43 | $this->assertEquals( 44 | $validator->computeSignature($uri, $params), $expected); 45 | $this->assertTrue($validator->validate($expected, $uri, $params)); 46 | } 47 | 48 | } 49 | -------------------------------------------------------------------------------- /vendor/twilio/sdk/tests/phpunit.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | ./ 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /vendor/twilio/sdk/tests/resources/AccountsTest.php: -------------------------------------------------------------------------------- 1 | 'application/x-www-form-urlencoded'); 8 | function testPost() 9 | { 10 | $http = m::mock(new Services_Twilio_TinyHttp); 11 | $http->shouldReceive('post')->once() 12 | ->with('/2010-04-01/Accounts.json', 13 | $this->formHeaders, 'FriendlyName=foo') 14 | ->andReturn(array(200, array('Content-Type' => 'application/json'), 15 | json_encode(array('sid' => 'AC345')) 16 | )); 17 | $client = new Services_Twilio('AC123', '123', '2010-04-01', $http); 18 | $account = $client->accounts->create(array( 19 | 'FriendlyName' => 'foo', 20 | )); 21 | $this->assertEquals('AC345', $account->sid); 22 | } 23 | 24 | function tearDown() 25 | { 26 | m::close(); 27 | } 28 | } 29 | 30 | -------------------------------------------------------------------------------- /vendor/twilio/sdk/tests/resources/ApplicationsTest.php: -------------------------------------------------------------------------------- 1 | 'application/x-www-form-urlencoded'); 7 | function testPost() 8 | { 9 | $http = m::mock(new Services_Twilio_TinyHttp); 10 | $http->shouldReceive('post')->once() 11 | ->with('/2010-04-01/Accounts/AC123/Applications.json', 12 | $this->formHeaders, 'FriendlyName=foo&VoiceUrl=bar') 13 | ->andReturn(array(200, array('Content-Type' => 'application/json'), 14 | json_encode(array('sid' => 'AP123')) 15 | )); 16 | $client = new Services_Twilio('AC123', '123', '2010-04-01', $http); 17 | $app = $client->account->applications->create('foo', array( 18 | 'VoiceUrl' => 'bar', 19 | )); 20 | $this->assertEquals('AP123', $app->sid); 21 | } 22 | 23 | function tearDown() 24 | { 25 | m::close(); 26 | } 27 | } 28 | 29 | -------------------------------------------------------------------------------- /vendor/twilio/sdk/tests/resources/AvailablePhoneNumbersTest.php: -------------------------------------------------------------------------------- 1 | shouldReceive('get')->once() 9 | ->with('/2010-04-01/Accounts/AC123/AvailablePhoneNumbers/US/Local.json?AreaCode=510') 10 | ->andReturn(array(200, array('Content-Type' => 'application/json'), 11 | json_encode(array('available_phone_numbers' => array( 12 | 'friendly_name' => '(510) 564-7903' 13 | ))) 14 | )); 15 | $client = new Services_Twilio('AC123', '123', '2010-04-01', $http); 16 | $nums = $client->account->available_phone_numbers->getLocal('US'); 17 | $numsList = $nums->getList(array('AreaCode' => '510')); 18 | foreach ($numsList as $num) { 19 | $this->assertEquals('(510) 564-7903', $num->friendly_name); 20 | } 21 | } 22 | 23 | function testPagePhoneNumberResource() { 24 | $http = m::mock(new Services_Twilio_TinyHttp); 25 | $http->shouldReceive('get')->once() 26 | ->with('/2010-04-01/Accounts/AC123/AvailablePhoneNumbers.json?Page=0&PageSize=50') 27 | ->andReturn(array(200, array('Content-Type' => 'application/json'), 28 | json_encode(array( 29 | 'total' => 1, 30 | 'countries' => array(array('country_code' => 'CA')) 31 | )) 32 | )); 33 | $client = new Services_Twilio('AC123', '123', '2010-04-01', $http); 34 | $page = $client->account->available_phone_numbers->getPage('0'); 35 | $this->assertEquals('CA', $page->countries[0]->country_code); 36 | } 37 | 38 | function testGetMobile() { 39 | $http = m::mock(new Services_Twilio_TinyHttp); 40 | $http->shouldReceive('get')->once() 41 | ->with('/2010-04-01/Accounts/AC123/AvailablePhoneNumbers/GB/Mobile.json') 42 | ->andReturn(array(200, array('Content-Type' => 'application/json'), 43 | json_encode(array('available_phone_numbers' => array( 44 | 'friendly_name' => '(510) 564-7903' 45 | ))) 46 | )); 47 | $client = new Services_Twilio('AC123', '123', '2010-04-01', $http); 48 | $nums = $client->account->available_phone_numbers->getMobile('GB')->getList(); 49 | foreach ($nums as $num) { 50 | $this->assertEquals('(510) 564-7903', $num->friendly_name); 51 | } 52 | } 53 | 54 | function tearDown() { 55 | m::close(); 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /vendor/twilio/sdk/tests/resources/CallsTest.php: -------------------------------------------------------------------------------- 1 | assertEquals($expected, $result); 13 | } 14 | 15 | function sidProvider() 16 | { 17 | return array( 18 | array("AP2a0747eba6abf96b7e3c3ff0b4530f6e", true), 19 | array("CA2a0747eba6abf96b7e3c3ff0b4530f6e", false), 20 | array("AP2a0747eba6abf96b7e3c3ff0b4530f", false), 21 | array("http://www.google.com/asdfasdfAP", false), 22 | ); 23 | } 24 | } 25 | 26 | -------------------------------------------------------------------------------- /vendor/twilio/sdk/tests/resources/ConnectAppsTest.php: -------------------------------------------------------------------------------- 1 | shouldReceive('get')->once() 10 | ->with('/2010-04-01/Accounts/AC123/ConnectApps/CN123.json') 11 | ->andReturn(array(200, array('Content-Type' => 'application/json'), 12 | json_encode(array('friendly_name' => 'foo')) 13 | )); 14 | $http->shouldReceive('post')->once() 15 | ->with('/2010-04-01/Accounts/AC123/ConnectApps/CN123.json', 16 | array('Content-Type' => 'application/x-www-form-urlencoded'), 17 | 'FriendlyName=Bar') 18 | ->andReturn(array(200, array('Content-Type' => 'application/json'), 19 | json_encode(array('friendly_name' => 'Bar')) 20 | )); 21 | $client = new Services_Twilio('AC123', '123', '2010-04-01', $http); 22 | $cn = $client->account->connect_apps->get('CN123'); 23 | $this->assertEquals('foo', $cn->friendly_name); 24 | $cn->update(array('FriendlyName' => 'Bar')); 25 | $this->assertEquals('Bar', $cn->friendly_name); 26 | } 27 | 28 | function testUpdateWithOneParam() 29 | { 30 | $http = m::mock(new Services_Twilio_TinyHttp); 31 | $http->shouldReceive('get')->once() 32 | ->with('/2010-04-01/Accounts/AC123/ConnectApps/CN123.json') 33 | ->andReturn(array(200, array('Content-Type' => 'application/json'), 34 | json_encode(array('friendly_name' => 'foo')) 35 | )); 36 | $http->shouldReceive('post')->once() 37 | ->with('/2010-04-01/Accounts/AC123/ConnectApps/CN123.json', 38 | array('Content-Type' => 'application/x-www-form-urlencoded'), 39 | 'FriendlyName=Bar') 40 | ->andReturn(array(200, array('Content-Type' => 'application/json'), 41 | json_encode(array('friendly_name' => 'Bar')) 42 | )); 43 | $client = new Services_Twilio('AC123', '123', '2010-04-01', $http); 44 | $cn = $client->account->connect_apps->get('CN123'); 45 | $this->assertEquals('foo', $cn->friendly_name); 46 | $cn->update('FriendlyName', 'Bar'); 47 | $this->assertEquals('Bar', $cn->friendly_name); 48 | } 49 | 50 | function tearDown() 51 | { 52 | m::close(); 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /vendor/twilio/sdk/tests/resources/IncomingPhoneNumbersTest.php: -------------------------------------------------------------------------------- 1 | array( 9 | array( 10 | 'sid' => 'PN123', 11 | 'sms_fallback_method' => 'POST', 12 | 'voice_method' => 'POST', 13 | 'friendly_name' => '(510) 564-7903', 14 | ) 15 | ), 16 | ); 17 | 18 | function testGetNumberWithResult() { 19 | $http = m::mock(new Services_Twilio_TinyHttp); 20 | $http->shouldReceive('get')->once() 21 | ->with('/2010-04-01/Accounts/AC123/IncomingPhoneNumbers.json?Page=0&PageSize=1&PhoneNumber=%2B14105551234') 22 | ->andReturn(array(200, array('Content-Type' => 'application/json'), 23 | json_encode($this->apiResponse) 24 | ) 25 | ); 26 | $client = new Services_Twilio('AC123', '123', '2010-04-01', $http); 27 | $number = $client->account->incoming_phone_numbers->getNumber('+14105551234'); 28 | $this->assertEquals('PN123', $number->sid); 29 | } 30 | 31 | function testGetNumberNoResults() { 32 | $http = m::mock(new Services_Twilio_TinyHttp); 33 | $http->shouldReceive('get')->once() 34 | ->with('/2010-04-01/Accounts/AC123/IncomingPhoneNumbers.json?Page=0&PageSize=1&PhoneNumber=%2B14105551234') 35 | ->andReturn(array(200, array('Content-Type' => 'application/json'), 36 | json_encode(array( 37 | 'incoming_phone_numbers' => array(), 38 | 'page' => 0, 39 | 'page_size' => 1, 40 | )) 41 | ) 42 | ); 43 | $client = new Services_Twilio('AC123', '123', '2010-04-01', $http); 44 | $number = $client->account->incoming_phone_numbers->getNumber('+14105551234'); 45 | $this->assertNull($number); 46 | } 47 | 48 | function testGetMobile() { 49 | $http = m::mock(new Services_Twilio_TinyHttp); 50 | $http->shouldReceive('get')->once() 51 | ->with('/2010-04-01/Accounts/AC123/IncomingPhoneNumbers/Mobile.json?Page=0&PageSize=50') 52 | ->andReturn(array(200, array('Content-Type' => 'application/json'), 53 | json_encode($this->apiResponse) 54 | )); 55 | $http->shouldReceive('get')->once() 56 | ->with('/2010-04-01/Accounts/AC123/IncomingPhoneNumbers/Mobile.json?Page=1&PageSize=50') 57 | ->andReturn(array(400, array('Content-Type' => 'application/json'), 58 | '{"status":400,"message":"foo", "code": "20006"}' 59 | )); 60 | $client = new Services_Twilio('AC123', '123', '2010-04-01', $http); 61 | foreach ($client->account->incoming_phone_numbers->mobile as $num) { 62 | $this->assertEquals('(510) 564-7903', $num->friendly_name); 63 | } 64 | } 65 | 66 | function testGetLocal() { 67 | $http = m::mock(new Services_Twilio_TinyHttp); 68 | $http->shouldReceive('get')->once() 69 | ->with('/2010-04-01/Accounts/AC123/IncomingPhoneNumbers/Local.json?Page=0&PageSize=50') 70 | ->andReturn(array(200, array('Content-Type' => 'application/json'), 71 | json_encode($this->apiResponse) 72 | )); 73 | $http->shouldReceive('get')->once() 74 | ->with('/2010-04-01/Accounts/AC123/IncomingPhoneNumbers/Local.json?Page=1&PageSize=50') 75 | ->andReturn(array(400, array('Content-Type' => 'application/json'), 76 | '{"status":400,"message":"foo", "code": "20006"}' 77 | )); 78 | $client = new Services_Twilio('AC123', '123', '2010-04-01', $http); 79 | 80 | foreach ($client->account->incoming_phone_numbers->local as $num) { 81 | $this->assertEquals('(510) 564-7903', $num->friendly_name); 82 | } 83 | } 84 | 85 | function testGetTollFree() { 86 | $http = m::mock(new Services_Twilio_TinyHttp); 87 | $http->shouldReceive('get')->once() 88 | ->with('/2010-04-01/Accounts/AC123/IncomingPhoneNumbers/TollFree.json?Page=0&PageSize=50') 89 | ->andReturn(array(200, array('Content-Type' => 'application/json'), 90 | json_encode($this->apiResponse) 91 | )); 92 | $http->shouldReceive('get')->once() 93 | ->with('/2010-04-01/Accounts/AC123/IncomingPhoneNumbers/TollFree.json?Page=1&PageSize=50') 94 | ->andReturn(array(400, array('Content-Type' => 'application/json'), 95 | '{"status":400,"message":"foo", "code": "20006"}' 96 | )); 97 | $client = new Services_Twilio('AC123', '123', '2010-04-01', $http); 98 | foreach ($client->account->incoming_phone_numbers->toll_free as $num) { 99 | $this->assertEquals('(510) 564-7903', $num->friendly_name); 100 | } 101 | } 102 | 103 | } 104 | 105 | -------------------------------------------------------------------------------- /vendor/twilio/sdk/tests/resources/MediaTest.php: -------------------------------------------------------------------------------- 1 | shouldReceive('get')->once() 10 | ->with('/2010-04-01/Accounts/AC123/Messages/MM123/Media.json?Page=0&PageSize=50') 11 | ->andReturn(array(200, array('Content-Type' => 'application/json'), 12 | json_encode(array( 13 | 'end' => '0', 14 | 'total' => '2', 15 | 'media_list' => array( 16 | array('sid' => 'ME123'), 17 | array('sid' => 'ME456') 18 | ), 19 | 'next_page_uri' => 'null', 20 | 'start' => 0 21 | )) 22 | )); 23 | $client = new Services_Twilio('AC123', '123', '2010-04-01', $http); 24 | $media_list = $client->account->messages->get('MM123')->media->getPage()->getItems(); 25 | $this->assertEquals(count($media_list), 2); 26 | } 27 | 28 | } 29 | -------------------------------------------------------------------------------- /vendor/twilio/sdk/tests/resources/MembersTest.php: -------------------------------------------------------------------------------- 1 | 'application/x-www-form-urlencoded'); 8 | 9 | function testFront() { 10 | $http = m::mock(new Services_Twilio_TinyHttp); 11 | $http->shouldReceive('get')->once() 12 | ->with('/2010-04-01/Accounts/AC123/Queues/QQ123/Members/Front.json') 13 | ->andReturn(array(200, array('Content-Type' => 'application/json'), 14 | json_encode(array('call_sid' => 'CA123', 'position' => 0)) 15 | )); 16 | $client = new Services_Twilio('AC123', '123', '2010-04-01', $http); 17 | $queue = $client->account->queues->get('QQ123'); 18 | $firstMember = $queue->members->front(); 19 | $this->assertSame($firstMember->call_sid, 'CA123'); 20 | } 21 | 22 | function testDequeueFront() { 23 | $http = m::mock(new Services_Twilio_TinyHttp); 24 | $http->shouldReceive('post')->once() 25 | ->with('/2010-04-01/Accounts/AC123/Queues/QQ123/Members/Front.json', 26 | $this->formHeaders, 'Url=http%3A%2F%2Ffoo.com&Method=POST') 27 | ->andReturn(array(200, array('Content-Type' => 'application/json'), 28 | json_encode(array('call_sid' => 'CA123', 'position' => 0)) 29 | )); 30 | $client = new Services_Twilio('AC123', '123', '2010-04-01', $http); 31 | $queue = $client->account->queues->get('QQ123'); 32 | $firstMember = $queue->members->front(); 33 | $firstMember->dequeue('http://foo.com'); 34 | } 35 | 36 | function testDequeueSid() { 37 | $http = m::mock(new Services_Twilio_TinyHttp); 38 | $http->shouldReceive('post')->once() 39 | ->with('/2010-04-01/Accounts/AC123/Queues/QQ123/Members/CA123.json', 40 | $this->formHeaders, 'Url=http%3A%2F%2Ffoo.com&Method=GET') 41 | ->andReturn(array(200, array('Content-Type' => 'application/json'), 42 | json_encode(array('call_sid' => 'CA123', 'position' => 0)) 43 | )); 44 | $client = new Services_Twilio('AC123', '123', '2010-04-01', $http); 45 | $queue = $client->account->queues->get('QQ123'); 46 | $firstMember = $queue->members->get('CA123'); 47 | $firstMember->dequeue('http://foo.com', 'GET'); 48 | } 49 | 50 | function testMemberIterate() { 51 | $http = m::mock(new Services_Twilio_TinyHttp); 52 | $resp = json_encode( 53 | array( 54 | 'queue_members' => array( 55 | array('call_sid' => 'CA123', 'wait_time' => 30) 56 | ), 57 | 'end' => 1, 58 | ) 59 | ); 60 | $http->shouldReceive('get')->once() 61 | ->with('/2010-04-01/Accounts/AC123/Queues/QQ123/Members.json?Page=0&PageSize=50') 62 | ->andReturn(array(200, array('Content-Type' => 'application/json'), $resp 63 | )); 64 | $http->shouldReceive('get')->once() 65 | ->with('/2010-04-01/Accounts/AC123/Queues/QQ123/Members.json?Page=1&PageSize=50') 66 | ->andReturn(array(400, array('Content-Type' => 'application/json'), 67 | '{"status":400,"message":"foo", "code": "20006"}' 68 | )); 69 | $client = new Services_Twilio('AC123', '123', '2010-04-01', $http); 70 | $queue = $client->account->queues->get('QQ123'); 71 | foreach($queue->members as $member) { 72 | $this->assertSame($member->call_sid, 'CA123'); 73 | $this->assertSame($member->wait_time, 30); 74 | } 75 | } 76 | 77 | function tearDown() { 78 | m::close(); 79 | } 80 | 81 | } 82 | 83 | 84 | -------------------------------------------------------------------------------- /vendor/twilio/sdk/tests/resources/NotificationTest.php: -------------------------------------------------------------------------------- 1 | shouldReceive('delete')->once() 9 | ->with('/2010-04-01/Accounts/AC123/Notifications/NO123.json') 10 | ->andReturn(array(204, array(), '')); 11 | $client = new Services_Twilio('AC123', '123', '2010-04-01', $http); 12 | $client->account->notifications->delete('NO123'); 13 | } 14 | 15 | function tearDown() 16 | { 17 | m::close(); 18 | } 19 | } 20 | 21 | -------------------------------------------------------------------------------- /vendor/twilio/sdk/tests/resources/OutgoingCallerIdsTest.php: -------------------------------------------------------------------------------- 1 | 'application/x-www-form-urlencoded'); 7 | function testPost() { 8 | $http = m::mock(new Services_Twilio_TinyHttp); 9 | $http->shouldReceive('post')->once() 10 | ->with('/2010-04-01/Accounts/AC123/OutgoingCallerIds.json', 11 | $this->formHeaders, 'PhoneNumber=%2B14158675309&FriendlyName=My+Home+Phone+Number') 12 | ->andReturn(array(200, array('Content-Type' => 'application/json'), 13 | json_encode(array( 14 | 'account_sid' => 'AC123', 15 | 'phone_number' => '+14158675309', 16 | 'friendly_name' => 'My Home Phone Number', 17 | 'validation_code' => 123456, 18 | )) 19 | )); 20 | $client = new Services_Twilio('AC123', '123', '2010-04-01', $http); 21 | $request = $client->account->outgoing_caller_ids->create('+14158675309', array( 22 | 'FriendlyName' => 'My Home Phone Number', 23 | )); 24 | $this->assertEquals(123456, $request->validation_code); 25 | } 26 | 27 | function tearDown() { 28 | m::close(); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /vendor/twilio/sdk/tests/resources/QueuesTest.php: -------------------------------------------------------------------------------- 1 | 'application/x-www-form-urlencoded'); 8 | 9 | function testCreate() { 10 | $http = m::mock(new Services_Twilio_TinyHttp); 11 | $http->shouldReceive('post')->once() 12 | ->with('/2010-04-01/Accounts/AC123/Queues.json', $this->formHeaders, 13 | 'FriendlyName=foo&MaxSize=123') 14 | ->andReturn(array(200, array('Content-Type' => 'application/json'), 15 | json_encode(array('sid' => 'QQ123', 'average_wait_time' => 0)) 16 | )); 17 | $client = new Services_Twilio('AC123', '123', '2010-04-01', $http); 18 | $queue = $client->account->queues->create('foo', 19 | array('MaxSize' => 123)); 20 | $this->assertSame($queue->sid, 'QQ123'); 21 | $this->assertSame($queue->average_wait_time, 0); 22 | } 23 | 24 | function tearDown() { 25 | m::close(); 26 | } 27 | } 28 | 29 | -------------------------------------------------------------------------------- /vendor/twilio/sdk/tests/resources/SMSMessagesTest.php: -------------------------------------------------------------------------------- 1 | 'application/x-www-form-urlencoded'); 7 | 8 | function testCreateMessage() { 9 | $http = m::mock(new Services_Twilio_TinyHttp); 10 | $http->shouldReceive('post')->once() 11 | ->with('/2010-04-01/Accounts/AC123/SMS/Messages.json', $this->formHeaders, 12 | 'From=%2B1222&To=%2B44123&Body=Hi+there') 13 | ->andReturn(array(200, array('Content-Type' => 'application/json'), 14 | json_encode(array('sid' => 'SM123')) 15 | )); 16 | $client = new Services_Twilio('AC123', '123', '2010-04-01', $http); 17 | $sms = $client->account->sms_messages->create('+1222', '+44123', 'Hi there'); 18 | $this->assertSame('SM123', $sms->sid); 19 | } 20 | 21 | function testBadMessageThrowsException() { 22 | $this->setExpectedException('Services_Twilio_RestException'); 23 | $http = m::mock(new Services_Twilio_TinyHttp); 24 | $http->shouldReceive('post')->once() 25 | ->with('/2010-04-01/Accounts/AC123/SMS/Messages.json', $this->formHeaders, 26 | 'From=%2B1222&To=%2B44123&Body=' . str_repeat('hi', 81)) 27 | ->andReturn(array(400, array('Content-Type' => 'application/json'), 28 | json_encode(array( 29 | 'status' => '400', 30 | 'message' => 'Too long', 31 | )) 32 | )); 33 | $client = new Services_Twilio('AC123', '123', null, $http); 34 | $sms = $client->account->sms_messages->create('+1222', '+44123', 35 | str_repeat('hi', 81)); 36 | } 37 | } 38 | 39 | -------------------------------------------------------------------------------- /vendor/twilio/sdk/tests/resources/SandboxTest.php: -------------------------------------------------------------------------------- 1 | 'application/x-www-form-urlencoded'); 7 | function testUpdateVoiceUrl() 8 | { 9 | $http = m::mock(new Services_Twilio_TinyHttp); 10 | $http->shouldReceive('post')->once() 11 | ->with('/2010-04-01/Accounts/AC123/Sandbox.json', $this->formHeaders, 'VoiceUrl=foo') 12 | ->andReturn(array(200, array('Content-Type' => 'application/json'), 13 | json_encode(array('voice_url' => 'foo')) 14 | )); 15 | $client = new Services_Twilio('AC123', '123', '2010-04-01', $http); 16 | $client->account->sandbox->update('VoiceUrl', 'foo'); 17 | $this->assertEquals('foo', $client->account->sandbox->voice_url); 18 | } 19 | 20 | function tearDown() { 21 | m::close(); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /vendor/twilio/sdk/tests/resources/ShortCodesTest.php: -------------------------------------------------------------------------------- 1 | shouldReceive('get')->once() 10 | ->with('/2010-04-01/Accounts/AC123/SMS/ShortCodes/SC123.json') 11 | ->andReturn(array(200, array('Content-Type' => 'application/json'), 12 | json_encode(array('sid' => 'SC123', 'short_code' => '1234')) 13 | )); 14 | $client = new Services_Twilio('AC123', '123', '2010-04-01', $http); 15 | $sms = $client->account->short_codes->get('SC123'); 16 | $this->assertSame('1234', $sms->short_code); 17 | } 18 | } 19 | 20 | -------------------------------------------------------------------------------- /vendor/twilio/sdk/tests/resources/UsageTriggersTest.php: -------------------------------------------------------------------------------- 1 | shouldReceive('get')->once() 9 | ->with('/2010-04-01/Accounts/AC123/Usage/Triggers/UT123.json') 10 | ->andReturn(array(200, array('Content-Type' => 'application/json'), 11 | json_encode(array( 12 | 'sid' => 'UT123', 13 | 'date_created' => 'Tue, 09 Oct 2012 19:27:24 +0000', 14 | 'recurring' => null, 15 | 'usage_category' => 'totalprice', 16 | )) 17 | )); 18 | $client = new Services_Twilio('AC123', '456bef', '2010-04-01', $http); 19 | $usageSid = 'UT123'; 20 | $usageTrigger = $client->account->usage_triggers->get($usageSid); 21 | $this->assertSame('totalprice', $usageTrigger->usage_category); 22 | } 23 | 24 | protected $formHeaders = array('Content-Type' => 'application/x-www-form-urlencoded'); 25 | 26 | function testUpdateTrigger() { 27 | $http = m::mock(new Services_Twilio_TinyHttp); 28 | $usageSid = 'UT123'; 29 | $http->shouldReceive('post')->once() 30 | ->with('/2010-04-01/Accounts/AC123/Usage/Triggers/UT123.json', 31 | $this->formHeaders, 'FriendlyName=new') 32 | ->andReturn(array(200, array('Content-Type' => 'application/json'), 33 | json_encode(array( 34 | 'friendly_name' => 'new', 35 | 'sid' => 'UT123', 36 | 'uri' => '/2010-04-01/Accounts/AC123/Usage/Triggers/UT123.json' 37 | )) 38 | )); 39 | $http->shouldReceive('get')->once() 40 | ->with('/2010-04-01/Accounts/AC123/Usage/Triggers/UT123.json') 41 | ->andReturn(array(200, array('Content-Type' => 'application/json'), 42 | json_encode(array( 43 | 'sid' => 'UT123', 44 | 'friendly_name' => 'new', 45 | )) 46 | )); 47 | $client = new Services_Twilio('AC123', '456bef', '2010-04-01', $http); 48 | $usageTrigger = $client->account->usage_triggers->get($usageSid); 49 | $usageTrigger->update(array( 50 | 'FriendlyName' => 'new', 51 | )); 52 | $usageTrigger2 = $client->account->usage_triggers->get($usageSid); 53 | $this->assertSame('new', $usageTrigger2->friendly_name); 54 | } 55 | 56 | function testFilterTriggerList() { 57 | $http = m::mock(new Services_Twilio_TinyHttp); 58 | $params = 'Page=0&PageSize=50&UsageCategory=sms'; 59 | $http->shouldReceive('get')->once() 60 | ->with('/2010-04-01/Accounts/AC123/Usage/Triggers.json?' . $params) 61 | ->andReturn(array(200, array('Content-Type' => 'application/json'), 62 | json_encode(array('usage_triggers' => array( 63 | array( 64 | 'usage_category' => 'sms', 65 | 'current_value' => '4', 66 | 'trigger_value' => '100.30', 67 | ), 68 | array( 69 | 'usage_category' => 'sms', 70 | 'current_value' => '4', 71 | 'trigger_value' => '400.30', 72 | )), 73 | 'next_page_uri' => '/2010-04-01/Accounts/AC123/Usage/Triggers.json?UsageCategory=sms&Page=1&PageSize=50', 74 | )) 75 | )); 76 | $params = 'UsageCategory=sms&Page=1&PageSize=50'; 77 | $http->shouldReceive('get')->once() 78 | ->with('/2010-04-01/Accounts/AC123/Usage/Triggers.json?' . $params) 79 | ->andReturn(array(400, array('Content-Type' => 'application/json'), 80 | '{"status":400,"message":"foo", "code": "20006"}' 81 | )); 82 | $client = new Services_Twilio('AC123', '456bef', '2010-04-01', $http); 83 | foreach ($client->account->usage_triggers->getIterator( 84 | 0, 50, array( 85 | 'UsageCategory' => 'sms', 86 | )) as $trigger 87 | ) { 88 | $this->assertSame($trigger->current_value, "4"); 89 | } 90 | } 91 | 92 | function testCreateTrigger() { 93 | $http = m::mock(new Services_Twilio_TinyHttp); 94 | $params = 'UsageCategory=sms&TriggerValue=100&CallbackUrl=foo'; 95 | $http->shouldReceive('post')->once() 96 | ->with('/2010-04-01/Accounts/AC123/Usage/Triggers.json', 97 | $this->formHeaders, $params) 98 | ->andReturn(array(201, array('Content-Type' => 'application/json'), 99 | json_encode(array( 100 | 'usage_category' => 'sms', 101 | 'sid' => 'UT123', 102 | 'uri' => '/2010-04-01/Accounts/AC123/Usage/Triggers/UT123.json' 103 | )) 104 | )); 105 | $client = new Services_Twilio('AC123', '456bef', '2010-04-01', $http); 106 | $trigger = $client->account->usage_triggers->create( 107 | 'sms', 108 | '100', 109 | 'foo' 110 | ); 111 | $this->assertSame('sms', $trigger->usage_category); 112 | } 113 | } 114 | 115 | --------------------------------------------------------------------------------