Permalink
Browse files

added support for specifying custom headers when using ->request. (Is…

…sue #98)
  • Loading branch information...
1 parent a1cd97b commit aae09443f8c5daa2940fb0c80c1b72fa66d313ba themattharris committed Nov 1, 2012
Showing with 15 additions and 8 deletions.
  1. +6 −4 README.md
  2. +9 −4 tmhOAuth.php
View
@@ -48,11 +48,13 @@ If you used custom HTTP request headers when they were defined as `'key: value'`
you should now define them as `'key' => 'value'` pairs.
## Change History
-### 0.7.2 - TBD
+### 0.7.2 - 01 November 2012
- use DIRECTORY_SEPARATOR for multi-environment support. (Issue #80) Props: whallz
- tidied up the curlHeader function to use explode instead of substr and store the keys in the format they are returned from the API
-- remove content-length, and expects header hacks. these aren't needed if CURLOPT_POSTFIELDS is initialized on all POSTs.
+- removed content-length hack as it isn't needed if CURLOPT_POSTFIELDS is initialized on all POSTs
+- removed the expects header hack as Twitter no longer requires it to be there
- introduce composer.json. (Issues #39, #77, #85) Props: akandels, conradkleinespel, dguyon, kud, philsturgeon, willdurand
+- added support for specifying custom headers when using $tmhOAuth->request. (Issue #98)
### 0.7.1 - 27 October 2012
- set content-length to 0 explictly to avoid a bug between libcurl and Twitter (Issue #94)
@@ -180,8 +182,8 @@ you should now define them as `'key' => 'value'` pairs.
License: Apache 2 (see [included LICENSE file](https://github.com/themattharris/tmhOAuth/blob/master/LICENSE))
-Follow [@tmhOAuth](https://twitter.com/intent/follow?screen_name=tmhOAuth) to receive updates on releases, or ask for support
-Follow me on Twitter: [@themattharris](https://twitter.com/intent/follow?screen_name=themattharris)
+Follow [@tmhOAuth](https://twitter.com/intent/follow?screen_name=tmhOAuth) to receive updates on releases, or ask for support
+Follow me on Twitter: [@themattharris](https://twitter.com/intent/follow?screen_name=themattharris)
Check out the Twitter Developer Resources: <https://dev.twitter.com>
## To Do
View
@@ -9,7 +9,7 @@
* @author themattharris
* @version 0.7.2-devel
*
- * 28 October 2012
+ * 01 November 2012
*/
class tmhOAuth {
const VERSION = '0.7.2-devel';
@@ -392,17 +392,22 @@ private function sign($method, $url, $params, $useauth) {
*
* @param string $method the HTTP method being used. e.g. POST, GET, HEAD etc
* @param string $url the request URL without query string parameters
- * @param array $params the request parameters as an array of key=value pairs
- * @param string $useauth whether to use authentication when making the request. Default true.
+ * @param array $params the request parameters as an array of key=value pairs. Default empty array
+ * @param string $useauth whether to use authentication when making the request. Default true
* @param string $multipart whether this request contains multipart data. Default false
+ * @param array $headers any custom headers to send with the request. Default empty array
*/
- public function request($method, $url, $params=array(), $useauth=true, $multipart=false) {
+ public function request($method, $url, $params=array(), $useauth=true, $multipart=false, $headers=array()) {
$this->config['multipart'] = $multipart;
$this->create_nonce();
$this->create_timestamp();
$this->sign($method, $url, $params, $useauth);
+
+ if (!empty($headers))
+ $this->headers = array_merge((array)$this->headers, (array)$headers);
+
return $this->curlit();
}

0 comments on commit aae0944

Please sign in to comment.