2011-03-16 1 views
2

누군가 내 코드를 아래에서 체크 아웃 할 수 있습니까? 나는 Vzaar (.com)와의 의사 소통을 시도하고 있으며 승인 할 수 없습니다. 내가 올바른 Authorization 헤더를 보내고있는 것 같지만 100 % 아니에요. 나는 그 밖의 무엇을 생각할 수 없다.Zend_Oauth의 문제점

class Vzaar { 
    /** 
    * 
    * @var Zend_Oauth_Token_Access 
    */ 
    protected $_oAuth; 
    /** 
    * 
    * @var Zend_Oauth_Client 
    */ 
    protected $_oClient; 
    protected $_sUsername; 
    protected $_sSecret; 
    protected $_sEndPoint = 'http://vzaar.com/api/'; 

    public function __construct($sUsername, $sSecret) { 
     $this->_sUsername = $sUsername; 
     $this->_sSecret = $sSecret; 
     $this->_oAuth = new Zend_Oauth_Token_Access(); 
     $this->_oAuth->setToken($this->_sUsername); 
     $this->_oAuth->setTokenSecret($this->_sSecret); 
     $this->_oClient = $this->_oAuth->getHttpClient(array()); 
    } 

    public function getVideos($sUsername = null) { 
     if (null === $sUsername) { 
      $sUsername = $this->_sUsername; 
     } 
     return $this->_request($sUsername . '/videos'); 
    } 

    protected function _request($sUri) { 
     $this->_oClient->setUri($this->_sEndPoint . 'test/whoami'); 
     $this->_oClient->setUri($this->_sEndPoint . $sUri . '.json'); 
     $this->_oClient->prepareOauth(); 
     Zend_Debug::dump($this->_oClient->getUri(true)); 
     Zend_Debug::dump($this->_oClient->getHeader('Authorization')); 
     $oRequest = $this->_oClient->request(); 
     Zend_Debug::dump($oRequest->getHeaders()); 
     Zend_Debug::dump($oRequest->getRawBody()); 

     return Zend_Json::decode($oRequest->getBody()); 
    } 

} 

답변

2

문제는 API에서만 허용되는 GET 요청입니다. 도!

public function __construct($sUsername, $sSecret) { 
    /*** snip ***/ 
    $this->_oClient = $this->_oAuth->getHttpClient(array(
     'requestMethod' => Zend_Oauth_Client::GET 
    )); 
    /*** snip ***/ 
}