Пример #1
0
 /**
  * Return complete callback URL or boolean FALSE if no callback provided
  *
  * @param Mage_Oauth_Model_Token $token Token object
  * @param bool $rejected OPTIONAL Add user reject sign
  * @return bool|string
  */
 public function getFullCallbackUrl(Mage_Oauth_Model_Token $token, $rejected = false)
 {
     $callbackUrl = $token->getCallbackUrl();
     if (Mage_Oauth_Model_Server::CALLBACK_ESTABLISHED == $callbackUrl) {
         return false;
     }
     if ($rejected) {
         /** @var $consumer Mage_Oauth_Model_Consumer */
         $consumer = Mage::getModel('oauth/consumer')->load($token->getConsumerId());
         if ($consumer->getId() && $consumer->getRejectedCallbackUrl()) {
             $callbackUrl = $consumer->getRejectedCallbackUrl();
         }
     } elseif (!$token->getAuthorized()) {
         Mage::throwException('Token is not authorized');
     }
     $callbackUrl .= false === strpos($callbackUrl, '?') ? '?' : '&';
     $callbackUrl .= 'oauth_token=' . $token->getToken() . '&';
     $callbackUrl .= $rejected ? self::QUERY_PARAM_REJECTED . '=1' : 'oauth_verifier=' . $token->getVerifier();
     return $callbackUrl;
 }