Exemplo n.º 1
0
 /**
  * Returns the URL used for login. 
  * 
  * @param string
  * @return string
  */
 public function getLoginUrl($redirect)
 {
     //Argument 1 must be a string
     Eden_Getsatisfaction_Error::i()->argument(1, 'string');
     //get the token
     $token = Eden_Oauth::i()->consumer(self::REQUEST_URL, $this->_key, $this->_secret)->useAuthorization()->setMethodToPost()->setSignatureToHmacSha1()->getQueryResponse();
     //to avoid any unesissary usage of persistent data,
     //we are going to attach the secret to the login URL
     $secret = self::SECRET_KEY . '=' . $token['oauth_token_secret'];
     //determine the conector
     $connector = NULL;
     //if there is no question mark
     if (strpos($redirect, '?') === false) {
         $connector = '?';
         //if the redirect doesn't end with a question mark
     } else {
         if (substr($redirect, -1) != '?') {
             $connector = '&';
         }
     }
     //now add the secret to the redirect
     $redirect .= $connector . $secret;
     //build the query
     $query = array('oauth_token' => $token['oauth_token'], 'oauth_callback' => $redirect);
     $query = http_build_query($query);
     return self::AUTHORIZE_URL . '?' . $query;
 }
 protected function _post($url, $query = array(), $jsonEncode = false)
 {
     $rest = Eden_Oauth::i()->getConsumer($url, $this->_consumerKey, $this->_consumerSecret)->setToken($this->_accessToken, $this->_accessSecret)->setMethodToPost()->useAuthorization()->setSignatureToHmacSha1();
     if ($jsonEncode) {
         $rest->jsonEncodeQuery();
     }
     $response = $rest->getJsonResponse($query);
     $this->_meta = $rest->getMeta();
     return $response;
 }
 protected function _post($url, $query = array())
 {
     $headers = array();
     $headers[] = Eden_Oauth_Consumer::POST_HEADER;
     $rest = Eden_Oauth::i()->getConsumer($url, $this->_consumerKey, $this->_consumerSecret)->setToken($this->_accessToken, $this->_accessSecret)->setSignatureToHmacSha1();
     //get the authorization parameters as an array
     $signature = $rest->getSignature();
     $authorization = $rest->getAuthorization($signature, false);
     $authorization = $this->_buildQuery($authorization);
     if (is_array($query)) {
         $query = $this->_buildQuery($query);
     }
     //determine the conector
     $connector = NULL;
     //if there is no question mark
     if (strpos($url, '?') === false) {
         $connector = '?';
         //if the redirect doesn't end with a question mark
     } else {
         if (substr($url, -1) != '?') {
             $connector = '&';
         }
     }
     //now add the authorization to the url
     $url .= $connector . $authorization;
     //set curl
     $curl = Eden_Curl::i()->verifyHost(false)->verifyPeer(false)->setUrl($url)->setPost(true)->setPostFields($query)->setHeaders($headers);
     //get the response
     $response = $curl->getResponse();
     $this->_meta = $curl->getMeta();
     $this->_meta['url'] = $url;
     $this->_meta['authorization'] = $authorization;
     $this->_meta['headers'] = $headers;
     $this->_meta['query'] = $query;
     return $response;
 }
 /**
  * Return a request token
  * 
  * @return string
  */
 public function getRequestToken()
 {
     return Eden_Oauth::i()->getConsumer(self::REQUEST_URL, $this->_key, $this->_secret)->useAuthorization()->setMethodToPost()->setSignatureToHmacSha1()->getQueryResponse();
 }
Exemplo n.º 5
0
 public function getLoginUrl($redirect)
 {
     Eden_Getsatisfaction_Error::i()->argument(1, 'string');
     $token = Eden_Oauth::i()->getConsumer(self::REQUEST_URL, $this->_key, $this->_secret)->useAuthorization()->setMethodToPost()->setSignatureToHmacSha1()->getQueryResponse();
     $secret = self::SECRET_KEY . '=' . $token['oauth_token_secret'];
     $connector = NULL;
     if (strpos($redirect, '?') === false) {
         $connector = '?';
     } else {
         if (substr($redirect, -1) != '?') {
             $connector = '&';
         }
     }
     $redirect .= $connector . $secret;
     $query = array('oauth_token' => $token['oauth_token'], 'oauth_callback' => $redirect);
     $query = http_build_query($query);
     return self::AUTHORIZE_URL . '?' . $query;
 }