Bastian Hofmann

added support for addtional headers to be passed to callApiEndpoint, see https:/…

…/github.com/vznet/oauth_2.0_client_php/issues#issue/4
@@ -247,9 +247,10 @@ class OAuth2_Service @@ -247,9 +247,10 @@ class OAuth2_Service
247 * @param string $method default 'GET' 247 * @param string $method default 'GET'
248 * @param array $uriParameters optional 248 * @param array $uriParameters optional
249 * @param mixed $postBody optional, can be string or array 249 * @param mixed $postBody optional, can be string or array
  250 + * @param array $additionalHeaders
250 * @return string 251 * @return string
251 */ 252 */
252 - public function callApiEndpoint($endpoint, $method = 'GET', array $uriParameters = array(), $postBody = null) { 253 + public function callApiEndpoint($endpoint, $method = 'GET', array $uriParameters = array(), $postBody = null, array $additionalHeaders = array()) {
253 $token = $this->_dataStore->retrieveAccessToken(); 254 $token = $this->_dataStore->retrieveAccessToken();
254 255
255 //check if token is invalid 256 //check if token is invalid
@@ -283,9 +284,9 @@ class OAuth2_Service @@ -283,9 +284,9 @@ class OAuth2_Service
283 $endpoint .= (strpos($endpoint, '?') !== false ? '&' : '?') . http_build_query($uriParameters); 284 $endpoint .= (strpos($endpoint, '?') !== false ? '&' : '?') . http_build_query($uriParameters);
284 } 285 }
285 286
286 - $header = array('Authorization: OAuth ' . $token->getAccessToken()); 287 + $headers = array_merge(array('Authorization: OAuth ' . $token->getAccessToken()), $additionalHeaders);
287 288
288 - $http = new OAuth2_HttpClient($endpoint, $method, $parameters, $header); 289 + $http = new OAuth2_HttpClient($endpoint, $method, $parameters, $headers);
289 $http->execute(); 290 $http->execute();
290 291
291 return $http->getResponse(); 292 return $http->getResponse();