Skip to content

Commit

Permalink
Merge pull request #1 from JavRok/patch-1
Browse files Browse the repository at this point in the history
Proposed changes for the API to work with Facebook OAuth v2. Instruction...
  • Loading branch information
ProLoser committed Nov 15, 2012
2 parents e9a2053 + 2f573b1 commit a72cde5
Showing 1 changed file with 23 additions and 1 deletion.
24 changes: 23 additions & 1 deletion Lib/HttpSocketOauth.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,11 @@ public function request($request = array()) {
// authorization header, for example, OAuth Echo as used by Twitpic and
// Twitter includes an Authorization Header as required by twitter's verify
// credentials API in the X-Verify-Credentials-Authorization header.
$request['header']['Authorization'] = $this->authorizationHeader($request);
if (isset($request['auth']['oauth_version']) && $request['auth']['oauth_version'] == '2.0'){
$request['header']['Authorization'] = $this->authorizationHeaderV2($request);
}else{
$request['header']['Authorization'] = $this->authorizationHeader($request);
}

// Now the Authorization header is built, fire the request off to the parent
// HttpSocket class request method that we intercepted earlier.
Expand Down Expand Up @@ -247,6 +251,24 @@ public function authorizationHeader($request) {

return $authorizationHeader;
}

/**
* Returns the OAuth V2 Authorization Header string for a given request array
* Old V1 params weren't accepted and returned error.
*
* @param array $request As required by HttpSocket::request(). NOTE ONLY
* THE ARRAY TYPE OF REQUEST IS SUPPORTED
* @return String
* @author Javier Rocamora
* @todo Check if other params are needed and build correctly
*/
public function authorizationHeaderV2($request) {

$authorizationHeader = 'OAuth ';
$authorizationHeader .= $request['auth']['access_token'];

return $authorizationHeader;
}

/**
* Builds an Authorization header param string from the supplied name and
Expand Down

0 comments on commit a72cde5

Please sign in to comment.