本文整理汇总了PHP中Zend_Gdata_HttpClient::setCookieJar方法的典型用法代码示例。如果您正苦于以下问题:PHP Zend_Gdata_HttpClient::setCookieJar方法的具体用法?PHP Zend_Gdata_HttpClient::setCookieJar怎么用?PHP Zend_Gdata_HttpClient::setCookieJar使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zend_Gdata_HttpClient
的用法示例。
在下文中一共展示了Zend_Gdata_HttpClient::setCookieJar方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getHttpClient
private function getHttpClient($userEmail, $password, $proxyHost = null, $proxyPort = null, $tries = 3)
{
$authenticationURL = Zend_Gdata_YouTube::CLIENTLOGIN_URL;
$service = Zend_Gdata_YouTube::AUTH_SERVICE_NAME;
if (isset($userEmail) && isset($password)) {
try {
if (isset($proxyHost) && isset($proxyPort)) {
$httpConfig = array('adapter' => 'Zend_Gdata_HttpAdapterStreamingProxy', 'proxy_host' => $proxyHost, 'proxy_port' => $proxyPort, 'maxredirects' => 5, 'timeout' => 120, 'keepalive' => true);
//$httpConfig = array ('adapter' => 'Zend_Http_Client_Adapter_Proxy', 'proxy_host' => $proxy->proxy, 'proxy_port' => $proxy->port,'maxredirects' => 10, 'timeout' => 120, 'keepalive' => true );
try {
// creates a proxied client to use for authentication
$clientp = new Zend_Gdata_HttpClient($authenticationURL, $httpConfig);
// To turn cookie stickiness on, set a Cookie Jar
$clientp->setCookieJar();
// authenticate
//$httpClient = Zend_Gdata_ClientLogin::getHttpClient ( $userEmail, $password, $service, $clientp );
$httpClient = Zend_Gdata_ClientLogin::getHttpClient($userEmail, $password, $service, $clientp, 'WePromoteThis.com', null, null, $authenticationURL);
// set the proxy information back into the client
// necessary due to http://framework.zend.com/issues/browse/ZF-1920
$httpClient->setConfig($httpConfig);
//echo ("Using Proxy: $proxyHost port: $proxyPort<br>");
} catch (Zend_Gdata_App_HttpException $e) {
//var_dump ( $e );
//echo ("Error Using Proxy: $proxyHost port: $proxyPort<br>" . $e->getMessage () . "<br>");
$httpClient = Zend_Gdata_ClientLogin::getHttpClient($userEmail, $password, $service, null, 'WePromoteThis.com', null, null, $authenticationURL);
}
} else {
//echo ("Not Using Proxy");
$httpClient = Zend_Gdata_ClientLogin::getHttpClient($userEmail, $password, $service, null, 'WePromoteThis.com', null, null, $authenticationURL);
}
} catch (Exception $e) {
//echo ("Error getting Youtube HttpClient: " . $e->getMessage () . "<br>");
$this->httpException = $e->getMessage();
}
} else {
//echo ("Credentials missing. Username: $userEmail | Password length: " . strlen ( $password ) . " <br>");
}
if (!isset($httpClient) && $tries > 0) {
sleep(30);
$httpClient = $this->getHttpClient($userEmail, $password, $proxyHost, $proxyPort, --$tries);
}
return $httpClient;
}