authorization, and I'd like to contribute it back to Zend. It's not
many changes - 2 member variables and setters/getters + 1
modification. I use http://oauth.googlecode.com/svn/code/php/OAuth.php
to get the OAuth-generated value of 'authorization' header - which is
under Apache2 license, so should be BSD-compatible - so we could have
a wrapper for it.
- Peter
Added to library/Zend/Gdata/HttpClient.php:
/** Value of 'Authorization:' header
*/
var $_oauthHeaderValue= null;
/** Value of 'xoauth_requestor_id' HTTP parameter that we append to
the request URLs. Not url-encoded, since
HttpClient will encode it itself.
*/
var $_xoauthRequestorId= null;
public function getOAuthHeaderValue() { return $this->_oauthHeaderValue; }
public function setOAuthHeaderValue( $value ) {
$this->_oauthHeaderValue= $value; }
public function getXoauthRequestorId() { return $this->xoauth_requestor_id; }
public function setXoauthRequestorId( $value ) {
$this->xoauth_requestor_id= $value; }
Modified in library/Zend/Gdata/HttpClient.php:
public function filterHttpRequest($method, $url, $headers =
array(), $body = null, $contentType = null) {
if ($this->getAuthSubToken() != null) {
// curent code...
}
} else
if ($this->getClientLoginToken() != null) {
$headers['authorization'] = 'GoogleLogin auth=' .
$this->getClientLoginToken();
}
elseif( $this->getOAuthHeaderValue() ) {
$headers['authorization']= $this->getOAuthHeaderValue();
}
if( $this->getXoauthRequestorId() ) {
$param_pair= 'xoauth_requestor_id=' .urlencode(
$this->getXoauthRequestorId() );
$separator= strpos($url, '?')===FALSE
? '?'
: '&';
$url.= $separator.$param_pair;
}
// current code...
没有评论:
发表评论