views:

257

answers:

1

Hello, i am using a youtube api php and have problem... OS: 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);

This code is empty return, but next code..

<?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);

has returned the object...

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
)

Why? Where a problem? Sorry for bah english

+1  A: 

.........

    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);

Instead of $yt, see what you have got in $feed eg:

    echo '<pre>';
    print_r($feed);

has returned the object...

This is because you are using print_r on object eg:

$yt = new Zend_Gdata_YouTube();
Sarfraz
$feed is empty =(
Isis
$query is too...
Isis
@Isis: $feed is empty because $query is empty, make sure that you specify the correct format in $searchTerm variable, try echoing it what does it contain.
Sarfraz
@Safraz: http://pastebin.com/m1021a3c0
Isis