X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=library%2FOAuth1.php;h=27ee090b114239499c8ac47f5bf04aeec2972ea4;hb=76ecf670663a52b3b9a0d8cc6dfd259404543de1;hp=67a94c4790b0648888ad630563c1284987faebef;hpb=5f2f64406407839d0a9d906e0ad165067d90d130;p=friendica.git diff --git a/library/OAuth1.php b/library/OAuth1.php index 67a94c4790..27ee090b11 100644 --- a/library/OAuth1.php +++ b/library/OAuth1.php @@ -3,8 +3,10 @@ /* Generic exception class */ -class OAuthException extends Exception { - // pass +if (!class_exists('OAuthException', false)) { + class OAuthException extends Exception { + // pass + } } class OAuthConsumer { @@ -27,6 +29,10 @@ class OAuthToken { public $key; public $secret; + public $expires; + public $scope; + public $uid; + /** * key = the token * secret = the token secret @@ -85,7 +91,7 @@ abstract class OAuthSignatureMethod { */ public function check_signature($request, $consumer, $token, $signature) { $built = $this->build_signature($request, $consumer, $token); - return $built == $signature; + return ($built == $signature); } } @@ -113,7 +119,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 +290,11 @@ class OAuthRequest { } } - + // fix for friendica redirect system + + $http_url = substr($http_url, 0, strpos($http_url,$parameters['pagename'])+strlen($parameters['pagename'])); + unset( $parameters['pagename'] ); + return new OAuthRequest($http_method, $http_url, $parameters); } @@ -409,8 +421,11 @@ class OAuthRequest { /** * builds the data one would send in a POST request */ - public function to_postdata() { - return OAuthUtil::build_http_query($this->parameters); + public function to_postdata($raw = false) { + if ($raw) + return($this->parameters); + else + return OAuthUtil::build_http_query($this->parameters); } /** @@ -642,6 +657,7 @@ class OAuthServer { $token, $signature ); + if (!$valid_sig) { throw new OAuthException("Invalid signature");