]> git.mxchange.org Git - friendica.git/blobdiff - library/OAuth1.php
Merge pull request #6964 from JeroenED/task/frio-sharestring-onchange
[friendica.git] / library / OAuth1.php
index 67a94c4790b0648888ad630563c1284987faebef..27ee090b114239499c8ac47f5bf04aeec2972ea4 100644 (file)
@@ -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");