Exemplo n.º 1
0
 /**
  * Obtains a request token from the specified provider.
  */
 public function obtainRequestToken($callbackUrl, $uid)
 {
     $callbackParams = (strpos($_SERVER['REQUEST_URI'], '?') !== false ? '&' : '?') . 'uid=' . urlencode($uid);
     $ret = $this->requestRequestToken($callbackUrl . $callbackParams);
     $matches = array();
     preg_match('/oauth_token=(.*)&oauth_token_secret=(.*)&oauth_callback_confirmed=(.*)/', $ret, $matches);
     if (!is_array($matches) || count($matches) != 4) {
         throw new apiAuthException("Error retrieving request key ({$ret})");
     }
     return new apiClientOAuthToken(apiClientOAuthUtil::urldecodeRFC3986($matches[1]), apiClientOAuthUtil::urldecodeRFC3986($matches[2]));
 }
Exemplo n.º 2
0
 /**
  * builds the Authorization: header
  */
 public function to_header()
 {
     $out = 'Authorization: OAuth ';
     $total = array();
     foreach ($this->parameters as $k => $v) {
         if (substr($k, 0, 5) != "oauth") {
             continue;
         }
         $out .= apiClientOAuthUtil::urlencodeRFC3986($k) . '="' . apiClientOAuthUtil::urlencodeRFC3986($v) . '", ';
     }
     $out = substr_replace($out, '', strlen($out) - 2);
     return $out;
 }