我正在使用youtube api php并且有问题...... 操作系统:debian,php 5.2
<?php
require_once 'Zend/Loader.php';
Zend_Loader::loadClass('Zend_Gdata_YouTube');
$yt = new Zend_Gdata_YouTube();
$query = $yt->newVideoQuery();
$query->setQuery($searchTerm);
$query->setStartIndex($startIndex);
$query->setMaxResults($maxResults);
$feed = $yt->getVideoFeed($query);
echo '<pre>';
print_r($yt);
此代码为空返回,但是下一个代码..
<?php
require_once 'Zend/Loader.php';
Zend_Loader::loadClass('Zend_Gdata_YouTube');
$yt = new Zend_Gdata_YouTube();
/*$query = $yt->newVideoQuery();
$query->setQuery($searchTerm);
$query->setStartIndex($startIndex);
$query->setMaxResults($maxResults);
$feed = $yt->getVideoFeed($query);*/
echo '<pre>';
print_r($yt);
返回了对象......
Zend_Gdata_YouTube Object
(
[_defaultPostUri:protected] =>
[_registeredPackages:protected] => Array
(
[0] => Zend_Gdata_Media_Extension
[1] => Zend_Gdata_Media
[2] => Zend_Gdata_YouTube_Extension
[3] => Zend_Gdata_YouTube
[4] => Zend_Gdata_Kind
[5] => Zend_Gdata_Extension
[6] => Zend_Gdata
[7] => Zend_Gdata_App_Extension
[8] => Zend_Gdata_App
)
[_httpClient:protected] => Zend_Http_Client Object
(
[config:protected] => Array
(
[maxredirects] => 5
[strictredirects] => 1
[useragent] => Zend_Http_Client
[timeout] => 10
[adapter] => Zend_Http_Client_Adapter_Socket
[httpversion] => 1.1
[keepalive] =>
[storeresponse] => 1
[strict] => 1
[output_stream] =>
)
[adapter:protected] =>
[uri:protected] =>
[headers:protected] => Array
(
[user-agent] => Array
(
[0] => User-Agent
[1] => MyCompany-MyApp-1.0 Zend_Framework_Gdata/1.10.0
)
)
[method:protected] => GET
[paramsGet:protected] => Array
(
)
[paramsPost:protected] => Array
(
)
[enctype:protected] =>
[raw_post_data:protected] =>
[auth:protected] =>
[files:protected] => Array
(
)
[cookiejar:protected] =>
[last_request:protected] =>
[last_response:protected] =>
[redirectCounter:protected] => 0
)
[_majorProtocolVersion:protected] =>
[_minorProtocolVersion:protected] =>
[_useObjectMapping:protected] => 1
)
为什么呢?哪里有问题? 抱歉bah english
答案 0 :(得分:1)
.........
require_once 'Zend/Loader.php';
Zend_Loader::loadClass('Zend_Gdata_YouTube');
$yt = new Zend_Gdata_YouTube();
$query = $yt->newVideoQuery();
$query->setQuery($searchTerm);
$query->setStartIndex($startIndex);
$query->setMaxResults($maxResults);
$feed = $yt->getVideoFeed($query);
echo '<pre>';
print_r($yt);
而不是$yt
,请参阅$feed
中的内容,例如:
echo '<pre>';
print_r($feed);
返回了对象......
这是因为您在对象上使用print_r
,例如:
$yt = new Zend_Gdata_YouTube();