summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormatt <matt@twilio.com>2016-08-18 14:29:08 -0700
committermatt <matt@twilio.com>2016-08-18 14:29:08 -0700
commit3476a559f7f18c01c2e67a8fc3a443433acc1777 (patch)
tree1c2d2a4bc405a8d77cbbde92fda94a48759b4709
parent18c61feb86698b123990f01cb260adea9c499ae6 (diff)
parentfe4fe265e4e53df2e1f99f748d2f16287d35bdef (diff)
downloadtwilio-php-5.0.3-alpha1.zip
twilio-php-5.0.3-alpha1.tar.gz
twilio-php-5.0.3-alpha1.tar.bz2
Merge branch 'master' into alpha5.0.3-alpha1
# Conflicts: # Twilio/VersionInfo.php
-rw-r--r--AUTHORS.md1
-rw-r--r--CHANGES.md7
-rw-r--r--README.md15
-rw-r--r--Twilio/Http/CurlClient.php7
-rw-r--r--Twilio/Tests/Unit/Http/CurlClientTest.php80
-rw-r--r--Twilio/VersionInfo.php2
6 files changed, 103 insertions, 9 deletions
diff --git a/AUTHORS.md b/AUTHORS.md
index 87aa291..bf08825 100644
--- a/AUTHORS.md
+++ b/AUTHORS.md
@@ -21,6 +21,7 @@ A huge thanks to all of our contributors:
- D. Keith Casey, Jr.
- Doug Black
- Elliot Lings
+- Jarod Reyes
- Jen Li
- Jingming Niu
- John Britton
diff --git a/CHANGES.md b/CHANGES.md
index 66fffc7..925fadf 100644
--- a/CHANGES.md
+++ b/CHANGES.md
@@ -1,6 +1,13 @@
twilio-php Changelog
====================
+Version 5.0.3
+-------------
+Released August 18, 2016
+
+- Adds the ability to pass options into `Twilio\Http\CurlClient`. This feature
+ brings `CurlClient` closer to parity with `Services_Twilio_TinyHttp`.
+
Version 5.0.2
-------------
Released August 16, 2016
diff --git a/README.md b/README.md
index 4b4246d..995bf5f 100644
--- a/README.md
+++ b/README.md
@@ -14,16 +14,17 @@ You can install **twilio-php** via composer or by downloading the source.
### Send an SMS
```php
+// Send an SMS using Twilio's REST API and PHP
<?php
-$sid = "ACXXXXXX"; // Your Account SID from www.twilio.com/user/account
-$token = "YYYYYY"; // Your Auth Token from www.twilio.com/user/account
+$sid = "ACXXXXXX"; // Your Account SID from www.twilio.com/console
+$token = "YYYYYY"; // Your Auth Token from www.twilio.com/console
$client = new Twilio\Rest\Client($sid, $token);
$message = $client->account->messages->create(
'9991231234', // From a valid Twilio number
'8881231234', // Text this number
array(
- 'Body' => "Hello monkey!"
+ 'Body' => "Hello from Twilio!"
)
);
@@ -34,8 +35,8 @@ print $message->sid;
```php
<?php
-$sid = "ACXXXXXX"; // Your Account SID from www.twilio.com/user/account
-$token = "YYYYYY"; // Your Auth Token from www.twilio.com/user/account
+$sid = "ACXXXXXX"; // Your Account SID from www.twilio.com/console
+$token = "YYYYYY"; // Your Auth Token from www.twilio.com/console
$client = new Twilio\Rest\Client($sid, $token);
$call = $client->account->calls->create(
@@ -92,6 +93,6 @@ If you need help installing or using the library, please contact Twilio Support
If you've instead found a bug in the library or would like new features added, go ahead and open issues or pull requests against this repo!
-[apidocs]: http://twilio.github.io/twilio-php/
-[documentation]: https://twilio.com/api/docs
+[apidocs]: https://twilio.com/api/docs
+[documentation]: http://twilio.github.io/twilio-php/
[versioning]: https://github.com/twilio/twilio-php/blob/master/VERSIONS.md
diff --git a/Twilio/Http/CurlClient.php b/Twilio/Http/CurlClient.php
index cbb4b0e..6fb2dda 100644
--- a/Twilio/Http/CurlClient.php
+++ b/Twilio/Http/CurlClient.php
@@ -8,6 +8,11 @@ use Twilio\Exceptions\EnvironmentException;
class CurlClient implements Client {
const DEFAULT_TIMEOUT = 60;
+ protected $curlOptions = array();
+
+ public function __construct(array $options = array()) {
+ $this->curlOptions = $options;
+ }
public function request($method, $url, $params = array(), $data = array(),
$headers = array(), $user = null, $password = null,
@@ -71,7 +76,7 @@ class CurlClient implements Client {
? self::DEFAULT_TIMEOUT
: $timeout;
- $options = array(
+ $options = $this->curlOptions + array(
CURLOPT_URL => $url,
CURLOPT_HEADER => true,
CURLOPT_RETURNTRANSFER => true,
diff --git a/Twilio/Tests/Unit/Http/CurlClientTest.php b/Twilio/Tests/Unit/Http/CurlClientTest.php
index b8725e0..2c6c952 100644
--- a/Twilio/Tests/Unit/Http/CurlClientTest.php
+++ b/Twilio/Tests/Unit/Http/CurlClientTest.php
@@ -229,4 +229,84 @@ class CurlClientTest extends UnitTest {
$this->assertEquals('a=1&b=2', fread($actual[CURLOPT_INFILE], $actual[CURLOPT_INFILESIZE]));
$this->assertEquals(7, $actual[CURLOPT_INFILESIZE]);
}
+
+ /**
+ * @param string $message Case message, displayed on assertion error
+ * @param mixed[] $options Options to inject
+ * @param mixed[] $expected Partial array to expect
+ * @dataProvider userInjectedOptionsProvider
+ */
+ public function testUserInjectedOptions($message, $options, $expected) {
+ $client = new CurlClient($options);
+ $actual = $client->options(
+ 'GET',
+ 'url',
+ array('param-key' => 'param-value'),
+ array('data-key' => 'data-value'),
+ array('header-key' => 'header-value'),
+ 'user',
+ 'password',
+ 20
+ );
+ foreach ($expected as $key => $value) {
+ $this->assertEquals($value, $actual[$key], $message);
+ }
+ }
+
+ public function userInjectedOptionsProvider() {
+ return array(
+ array(
+ 'No Conflict Options',
+ array(
+ CURLOPT_VERBOSE => true,
+ ),
+ array(
+ CURLOPT_VERBOSE => true,
+ ),
+ ),
+ array(
+ 'Options preferred over Defaults',
+ array(
+ CURLOPT_TIMEOUT => 1000,
+ ),
+ array(
+ CURLOPT_TIMEOUT => 1000,
+ ),
+ ),
+ array(
+ 'Required Options can not be injected',
+ array(
+ CURLOPT_HTTPGET => false,
+ ),
+ array(
+ CURLOPT_HTTPGET => true,
+ ),
+ ),
+ array(
+ 'Injected URL decorated with Query String',
+ array(
+ CURLOPT_URL => 'user-provided-url',
+ ),
+ array(
+ CURLOPT_URL => 'user-provided-url?param-key=param-value',
+ ),
+ ),
+ array(
+ 'Injected Headers are additive',
+ array(
+ CURLOPT_HTTPHEADER => array(
+ 'injected-key: injected-value',
+ ),
+ ),
+ array(
+ CURLOPT_HTTPHEADER => array(
+ 'injected-key: injected-value',
+ 'header-key: header-value',
+ 'Authorization: Basic ' . base64_encode('user:password'),
+ ),
+ ),
+ ),
+ );
+ }
+
}
diff --git a/Twilio/VersionInfo.php b/Twilio/VersionInfo.php
index 6bb689e..a0d51df 100644
--- a/Twilio/VersionInfo.php
+++ b/Twilio/VersionInfo.php
@@ -7,7 +7,7 @@ namespace Twilio;
class VersionInfo {
const MAJOR = 5;
const MINOR = 0;
- const PATCH = '2-alpha1';
+ const PATCH = '3-alpha1';
public static function string() {
return implode('.', array(self::MAJOR, self::MINOR, self::PATCH));