/** * @dataProvider right * * @param Sms $sms */ public function testShouldUseDefaultFromNumber(Sms $sms) { $twilio = $this->twilio->reveal(); $account = $this->prophesize(\Services_Twilio_Rest_Account::class); $messages = $this->prophesize(\Services_Twilio_Rest_Messages::class); $twilio->account = $account->reveal(); $twilio->account->messages = $messages->reveal(); $messages->create(['From' => '+393333333333', 'To' => '+393333333333', 'Body' => 'Foo Bar'])->shouldBeCalled(); $this->handler->setDefaultFrom('+393333333333'); $this->handler->notify($sms); }
function testNullVersionReturnsNewest() { $client = new Services_Twilio('AC123', '123', null); $this->assertEquals('2010-04-01', $client->getVersion()); $client = new Services_Twilio('AC123', '123', 'v1'); $this->assertEquals('2010-04-01', $client->getVersion()); $client = new Services_Twilio('AC123', '123', '2010-04-01'); $this->assertEquals('2010-04-01', $client->getVersion()); $client = new Services_Twilio('AC123', '123', '2008-08-01'); $this->assertEquals('2008-08-01', $client->getVersion()); }
public function __construct() { $decryptor = Mage::helper('core'); $this->accountSid = $decryptor->decrypt(Mage::getStoreConfig('twilio/config/account_sid')); $this->authToken = $decryptor->decrypt(Mage::getStoreConfig('twilio/config/auth_token')); parent::__construct($this->accountSid, $this->authToken); }
/** * Constructor * * Set up the twilio object and assign the numbers to use. */ public function __construct() { $decryptor = Mage::helper('core'); $this->AccountSid = Mage::helper('twilio')->getAccountSID(); $this->AuthToken = Mage::helper('twilio')->getAuthToken(); $this->twilioNumber = Mage::helper('twilio')->getTwilioNumber(); $this->smsNotificationNumber = Mage::helper('twilio')->getSMSNotificationNumber(); parent::__construct($this->AccountSid, $this->AuthToken); }
<?php // Download the library and copy into the folder containing this file. require 'vendor/twilio-php/Services/Twilio.php'; $account_sid = "Your Twilio account sid"; // Your Twilio account sid $auth_token = "Your Twilio auth token"; // Your Twilio auth token $client = new Services_Twilio($account_sid, $auth_token); $resourceName = $client->getResourceName(); $message = $client->account->messages->sendMessage('+447900000000', '+441253530197', "To Twilio printCode ZZZVVV"); echo $message->sid; echo $resourceName;
/** * @param string $sid * @param string $token * @param null $version * @param int $retryAttempts */ public function __construct($sid, $token, $version = null, $retryAttempts = 1) { parent::__construct($sid, $token, $version, null, $retryAttempts); }
private function update_connect_app($connect_app_sid) { if (!empty($connect_app_sid) && $this->tenant->id == VBX_PARENT_TENANT) { $account = OpenVBX::getAccount(); /** @var Services_Twilio_Rest_ConnectApp $connect_app */ $connect_app = $account->connect_apps->get($connect_app_sid); $required_settings = array('HomepageUrl' => site_url(), 'AuthorizeRedirectUrl' => site_url('/auth/connect'), 'DeauthorizeCallbackUrl' => site_url('/auth/connect/deauthorize'), 'Permissions' => array('get-all', 'post-all')); $updated = false; foreach ($required_settings as $key => $setting) { $app_key = Services_Twilio::decamelize($key); if ($connect_app->{$app_key} != $setting) { $connect_app->{$app_key} = $setting; $updated = true; } } if ($updated) { $connect_app->update(array('FriendlyName' => $connect_app->friendly_name, 'Description' => $connect_app->description, 'CompanyName' => $connect_app->company_name, 'HomepageUrl' => $required_settings['HomepageUrl'], 'AuthorizeRedirectUrl' => $required_settings['AuthorizeRedirectUrl'], 'DeauthorizeCallbackUrl' => $required_settings['DeauthorizeCallbackUrl'], 'Permissions' => implode(',', $required_settings['Permissions']))); } } }
private function setup_connect_app($settings) { try { $account = OpenVBX::getAccount($settings['twilio_sid'], $settings['twilio_token']); $connect_application = $account->connect_apps->get($settings['connect_application_sid']); if ($connect_application->sid == $settings['connect_application_sid']) { $site_url = site_url(); if ($settings['rewrite_enabled']) { $site_url = str_replace('/index.php', '', $site_url); } $required_settings = array('HomepageUrl' => $site_url, 'AuthorizeRedirectUrl' => $site_url . '/auth/connect', 'DeauthorizeCallbackUrl' => $site_url . '/auth/connect/deauthorize', 'Permissions' => array('get-all', 'post-all')); $updated = false; foreach ($required_settings as $key => $setting) { $app_key = Services_Twilio::decamelize($key); if ($connect_application->{$app_key} != $setting) { $connect_application->{$app_key} = $setting; $updated = true; } } if ($updated) { $connect_application->update(array('FriendlyName' => $connect_application->friendly_name, 'Description' => $connect_application->description, 'CompanyName' => $connect_application->company_name, 'HomepageUrl' => $required_settings['HomepageUrl'], 'AuthorizeRedirectUrl' => $required_settings['AuthorizeRedirectUrl'], 'DeauthorizeCallbackUrl' => $required_settings['DeauthorizeCallbackUrl'], 'Permissions' => implode(',', $required_settings['Permissions']))); } } } catch (Exception $e) { throw new InstallException($e->getMessage(), $e->getCode()); } }
public function testQualifiedUserAgent() { $expected = Services_Twilio::USER_AGENT . " (php 5.4)"; $this->assertEquals(Services_Twilio::qualifiedUserAgent("5.4"), $expected); }
/** * @param string $sid * @param string $token */ public function __construct($sid, $token) { parent::__construct($sid, $token); }
public function testKeylessDataPrefix() { $data = array('bar', 'baz', 'bin'); $this->assertEquals(Services_Twilio::buildQuery($data, 'var'), 'var0=bar&var1=baz&var2=bin'); }