diff options
author | fabrixxm <fabrix.xm@gmail.com> | 2011-11-08 00:18:37 -0800 |
---|---|---|
committer | fabrixxm <fabrix.xm@gmail.com> | 2011-11-08 00:18:37 -0800 |
commit | eeec29c6be2429ea38ab258591200e0178886a25 (patch) | |
tree | 09f54a745f7ec828914e3ba7ee90492b0804ffef /library/OAuth1.php | |
parent | 9fabdbf2c974211c8fef18e48a956f8f38bd9e74 (diff) | |
parent | c90e6c6e0782e3e8ac9cf1be3acbc13f5448148d (diff) | |
download | volse-hubzilla-eeec29c6be2429ea38ab258591200e0178886a25.tar.gz volse-hubzilla-eeec29c6be2429ea38ab258591200e0178886a25.tar.bz2 volse-hubzilla-eeec29c6be2429ea38ab258591200e0178886a25.zip |
Merge pull request #2 from fabrixxm/master
Oauth1 support in API
Diffstat (limited to 'library/OAuth1.php')
-rw-r--r-- | library/OAuth1.php | 20 |
1 files changed, 17 insertions, 3 deletions
diff --git a/library/OAuth1.php b/library/OAuth1.php index 67a94c479..3b211b146 100644 --- a/library/OAuth1.php +++ b/library/OAuth1.php @@ -27,6 +27,10 @@ class OAuthToken { public $key; public $secret; + public $expires; + public $scope; + public $uid; + /** * key = the token * secret = the token secret @@ -85,7 +89,8 @@ abstract class OAuthSignatureMethod { */ public function check_signature($request, $consumer, $token, $signature) { $built = $this->build_signature($request, $consumer, $token); - return $built == $signature; + //echo "<pre>"; var_dump($signature, $built, ($built == $signature)); killme(); + return ($built == $signature); } } @@ -113,7 +118,9 @@ class OAuthSignatureMethod_HMAC_SHA1 extends OAuthSignatureMethod { $key_parts = OAuthUtil::urlencode_rfc3986($key_parts); $key = implode('&', $key_parts); - return base64_encode(hash_hmac('sha1', $base_string, $key, true)); + + $r = base64_encode(hash_hmac('sha1', $base_string, $key, true)); + return $r; } } @@ -282,7 +289,12 @@ class OAuthRequest { } } - + // fix for friendika redirect system + + $http_url = substr($http_url, 0, strpos($http_url,$parameters['q'])+strlen($parameters['q'])); + unset( $parameters['q'] ); + + //echo "<pre>".__function__."\n"; var_dump($http_method, $http_url, $parameters, $_SERVER['REQUEST_URI']); killme(); return new OAuthRequest($http_method, $http_url, $parameters); } @@ -544,6 +556,7 @@ class OAuthServer { public function verify_request(&$request) { $this->get_version($request); $consumer = $this->get_consumer($request); + //echo __file__.__line__.__function__."<pre>"; var_dump($consumer); die(); $token = $this->get_token($request, $consumer, "access"); $this->check_signature($request, $consumer, $token); return array($consumer, $token); @@ -642,6 +655,7 @@ class OAuthServer { $token, $signature ); + if (!$valid_sig) { throw new OAuthException("Invalid signature"); |