本文整理汇总了PHP中Zend_Gdata_YouTube::getHttpClient方法的典型用法代码示例。如果您正苦于以下问题:PHP Zend_Gdata_YouTube::getHttpClient方法的具体用法?PHP Zend_Gdata_YouTube::getHttpClient怎么用?PHP Zend_Gdata_YouTube::getHttpClient使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zend_Gdata_YouTube
的用法示例。
在下文中一共展示了Zend_Gdata_YouTube::getHttpClient方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
public function __construct()
{
$this->yt = new Zend_Gdata_YouTube(null, 'vlc-shares/' . X_VlcShares::VERSION . ' youtube/' . self::VERSION, null, 'AI39si4HbHoRBg1vlyLlRARR1Bl2TWqUy4LuCFHpS6ZnZ2LxlqbCLrgh8kDBj-7h2lkDs99cvaOZRm-4p-GlEP2rxtD6BZ9dcg');
$this->yt->setMajorProtocolVersion(2);
$this->yt->getHttpClient()->setHeaders('User-Agent', 'vlc-shares/' . X_VlcShares::VERSION . ' youtube/' . self::VERSION);
$this->yt->setGzipEnabled(true);
}
示例2: set_transport_authentication_params
/**
*
* @return Bridge_Api_Youtube
*/
protected function set_transport_authentication_params()
{
if ($this->_auth->is_connected()) {
$signatures = $this->_auth->get_auth_signatures();
$this->_api->getHttpClient()->setAuthSubToken($signatures['auth_token']);
}
return $this;
}
示例3: testSetClientIDAndDeveloperKeyHeader
public function testSetClientIDAndDeveloperKeyHeader()
{
$applicationId = 'MyTestCompany-MyTestApp-0.1';
$clientId = 'MyClientId';
$developerKey = 'MyDeveloperKey';
$httpClient = new Zend_Http_Client();
$yt = new Zend_Gdata_YouTube($httpClient, $applicationId, $clientId, $developerKey);
$this->assertTrue($yt instanceof Zend_Gdata_YouTube);
$client = $yt->getHttpClient();
$this->assertEquals($client->getHeader('X-Gdata-Key'), 'key=' . $developerKey);
$this->assertEquals($client->getHeader('X-Gdata-Client'), $clientId);
}
示例4: searchVideos
/**
* Perform a search on youtube. Passes the result feed to echoVideoList.
*
* @param string $searchType The type of search to perform.
* If set to 'owner' then attempt to authenticate.
* @param string $searchTerm The term to search on.
* @param string $startIndex Start retrieving search results from this index.
* @param string $maxResults The number of results to retrieve.
* @return void
*/
function searchVideos($searchType, $searchTerm, $startIndex, $maxResults)
{
// create an unauthenticated service object
$youTubeService = new Zend_Gdata_YouTube();
$query = $youTubeService->newVideoQuery();
$query->setQuery($searchTerm);
$query->setStartIndex($startIndex);
$query->setMaxResults($maxResults);
switch ($searchType) {
case 'most_viewed':
$query->setFeedType('most viewed');
$query->setTime('this_week');
$feed = $youTubeService->getVideoFeed($query);
break;
case 'most_recent':
$query->setFeedType('most recent');
$query->setTime('this_week');
$feed = $youTubeService->getVideoFeed($query);
break;
case 'recently_featured':
$query->setFeedType('recently featured');
$feed = $youTubeService->getVideoFeed($query);
break;
case 'top_rated':
$query->setFeedType('top rated');
$query->setTime('this_week');
$feed = $youTubeService->getVideoFeed($query);
break;
case 'username':
$feed = $youTubeService->getUserUploads($searchTerm);
break;
case 'all':
$feed = $youTubeService->getVideoFeed($query);
break;
case 'owner':
$httpClient = getAuthSubHttpClient();
$youTubeService = new Zend_Gdata_YouTube($httpClient);
try {
$feed = $youTubeService->getUserUploads('default');
if (loggingEnabled()) {
logMessage($httpClient->getLastRequest(), 'request');
logMessage($httpClient->getLastResponse()->getBody(), 'response');
}
} catch (Zend_Gdata_App_HttpException $httpException) {
print 'ERROR ' . $httpException->getMessage() . ' HTTP details<br /><textarea cols="100" rows="20">' . $httpException->getRawResponseBody() . '</textarea><br />' . '<a href="session_details.php">' . 'click here to view details of last request</a><br />';
return;
} catch (Zend_Gdata_App_Exception $e) {
print 'ERROR - Could not retrieve users video feed: ' . $e->getMessage() . '<br />';
return;
}
echoVideoList($feed, true);
return;
default:
echo 'ERROR - Unknown search type - \'' . $searchType . '\'';
return;
}
if (loggingEnabled()) {
$httpClient = $youTubeService->getHttpClient();
logMessage($httpClient->getLastRequest(), 'request');
logMessage($httpClient->getLastResponse()->getBody(), 'response');
}
echoVideoList($feed);
}
示例5: getYoutubeVideoSuggestions
public function getYoutubeVideoSuggestions()
{
if (Mage::helper('videogallery')->isVideoSuggestionsEnabled() == false) {
return array();
}
if (!$this->_youtubeFeed) {
try {
$product = $this->getProduct();
if (!$product->getId()) {
return array();
}
$yt = new Zend_Gdata_YouTube();
$yt->getHttpClient()->setConfig(array('timeout' => 10));
$query = $yt->newVideoQuery();
$query->videoQuery = $product->getName() . ' ' . $product->getSku();
$query->startIndex = 0;
$query->maxResults = 5;
$results = $yt->getVideoFeed($query);
$this->_youtubeFeed = array();
foreach ($results as $video) {
if ($this->videoAlreadyAdded($video->getVideoId())) {
continue;
}
$this->_youtubeFeed[] = $video;
}
} catch (Exception $e) {
return "Error Retrieving Video Suggestions from Youtube: " . $e->getMessage();
}
}
return $this->_youtubeFeed;
}