本文整理汇总了PHP中Zend_Gdata_HttpClient::setAuthSubToken方法的典型用法代码示例。如果您正苦于以下问题:PHP Zend_Gdata_HttpClient::setAuthSubToken方法的具体用法?PHP Zend_Gdata_HttpClient::setAuthSubToken怎么用?PHP Zend_Gdata_HttpClient::setAuthSubToken使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zend_Gdata_HttpClient
的用法示例。
在下文中一共展示了Zend_Gdata_HttpClient::setAuthSubToken方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testSecureAuthSubSigning
public function testSecureAuthSubSigning()
{
if (!extension_loaded('openssl')) {
$this->markTestSkipped('The openssl extension is not available');
} else {
$c = new Zend_Gdata_HttpClient();
$c->setAuthSubPrivateKeyFile("Zend/Gdata/_files/RsaKey.pem", null, true);
$c->setAuthSubToken('abcdefg');
$requestData = $c->filterHttpRequest('POST', 'http://www.example.com/feed', array(), 'foo bar', 'text/plain');
$authHeaderCheckPassed = false;
$headers = $requestData['headers'];
foreach ($headers as $headerName => $headerValue) {
if (strtolower($headerName) == 'authorization') {
preg_match('/data="([^"]*)"/', $headerValue, $matches);
$dataToSign = $matches[1];
preg_match('/sig="([^"]*)"/', $headerValue, $matches);
$sig = $matches[1];
if (function_exists('openssl_verify')) {
$fp = fopen('Zend/Gdata/_files/RsaCert.pem', 'r', true);
$cert = '';
while (!feof($fp)) {
$cert .= fread($fp, 8192);
}
fclose($fp);
$pubkeyid = openssl_get_publickey($cert);
$verified = openssl_verify($dataToSign, base64_decode($sig), $pubkeyid);
$this->assertEquals(1, $verified, 'The generated signature was unable ' . 'to be verified.');
$authHeaderCheckPassed = true;
}
}
}
$this->assertEquals(true, $authHeaderCheckPassed, 'Auth header not found for sig verification.');
}
}
示例2: setupDocsClient
function setupDocsClient($token = null)
{
global $authSubURL;
$docsClient = null;
// Fetch a new AuthSub token?
if (!$token && !isset($_SESSION['sessionToken'])) {
$next = 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF'];
$scope = 'http://docs.google.com/feeds/ https://docs.google.com/feeds/';
$secure = 0;
$session = 1;
$permission = 1;
// 1 - allows posting notices && allows reading profile data
$authSubURL = Zend_Gdata_AuthSub::getAuthSubTokenUri($next, $scope, $secure, $session);
} else {
if (isset($_SESSION['sessionToken'])) {
$httpClient = new Zend_Gdata_HttpClient();
$httpClient->setAuthSubToken($_SESSION['sessionToken']);
$docsClient = new Zend_Gdata_Docs($httpClient, 'google-OCRPHPDemo-v0.1');
} else {
$httpClient = new Zend_Gdata_HttpClient();
$_SESSION['sessionToken'] = Zend_Gdata_AuthSub::getAuthSubSessionToken(trim($token), $httpClient);
$httpClient->setAuthSubToken($_SESSION['sessionToken']);
$docsClient = new Zend_Gdata_Docs($httpClient, 'google-OCRPHPDemo-v0.1');
}
}
return $docsClient;
}
示例3: picasaDelete
public function picasaDelete($photoId)
{
$token = $this->get_login_token();
$client = new Zend_Gdata_HttpClient();
$client->setAuthSubToken($token);
$client->setClientLoginToken($token);
$gphoto = new Zend_Gdata_Photos($client);
$photoQuery = $gphoto->newPhotoQuery();
$photoQuery->setUser($this->config['user']);
$photoQuery->setAlbumId($this->config['album_id']);
$photoQuery->setPhotoId($photoId);
$photoQuery->setType('entry');
$entry = $gphoto->getPhotoEntry($photoQuery);
$gphoto->deletePhotoEntry($entry, true);
}
示例4: getHttpClient
/**
* Retrieve a HTTP client object with AuthSub credentials attached
* as the Authorization header
*
* @param string $token The token to retrieve information about
* @param Zend_Gdata_HttpClient $client (optional) HTTP client to use to make the request
*/
public static function getHttpClient($token, $client = null)
{
if ($client == null) {
$client = new Zend_Gdata_HttpClient();
}
if (!$client instanceof Zend_Gdata_HttpClient) {
// require_once 'Zend/Gdata/App/HttpException.php';
throw new Zend_Gdata_App_HttpException('Client is not an instance of Zend_Gdata_HttpClient.');
}
$useragent = 'Zend_Framework_Gdata/' . Zend_Version::VERSION;
$client->setConfig(array('strictredirects' => true, 'useragent' => $useragent));
$client->setAuthSubToken($token);
return $client;
}
示例5: init
/**
* N.B.: A session token must be available before calling this method
*
* @return void
*/
public function init()
{
if (!is_object($this->service)) {
$pathToKey = sfConfig::get('sf_root_dir') . '/' . sfConfig::get('app_googleCalendarIntegration_privateKeyPath');
$client = new Zend_Gdata_HttpClient();
$client->setAuthSubPrivateKeyFile($pathToKey, null, true);
$sessionToken = $this->getSessionToken();
if (!$sessionToken) {
throw new Exception("GoogleCalendarInterface: missing session token");
}
$client->setAuthSubToken($sessionToken);
$this->service = new Zend_Gdata_Calendar($client, 'google-calendar-plancake-integration');
$this->service->setMajorProtocolVersion(2);
$this->service->setMinorProtocolVersion(null);
}
}