views:

1193

answers:

2

I am using Zend Gdata to interface with the YouTube API from a PHP script. I actually had this working fine, and suddenly I am getting a fatal error about a 'Zend_Uri_Exception' with message 'Invalid URI supplied'. How can I correct the exception?

CODE:

require_once 'Zend/Loader.php';
Zend_Loader::loadClass('Zend_Gdata_YouTube');

$yt = new Zend_Gdata_YouTube();
$query = $yt->newVideoQuery();
$query->setOrderBy($this->data['ItemVideo']['sort']);
$query->setRacy('include');
$query->setCategory($this->data['ItemVideo']['q']);

try {
  $videoFeed = $yt->getVideoFeed($query);
} catch(Exception $e) {
  echo var_dump($query) . '<p></p>' . $e;
}

OUTPUT:

object(Zend_Gdata_YouTube_VideoQuery)#79 (4) { ["_params:protected"]
=>  array(2) { ["orderby"]=>  string(9) "relevance" ["racy"]=>  string
(7) "include" } ["_defaultFeedUri:protected"]=>  NULL
["_url:protected"]=>  NULL ["_category:protected"]=>  string(14)
"charlie bit me" }

exception 'Zend_Uri_Exception' with message 'Invalid URI supplied' in /
web/php/balistik_list_app/app/vendors/ZendGdata/library/Zend/Uri/
Http.php:136 Stack trace: #0 /web/php/balistik_list_app/app/vendors/
ZendGdata/library/Zend/Uri.php(123): Zend_Uri_Http->__construct
('http', '//gdata.youtube...') #1 /web/php/balistik_list_app/app/
vendors/ZendGdata/library/Zend/Http/Client.php(257): Zend_Uri::factory
('http://gdata.yo...') #2 /web/php/balistik_list_app/app/vendors/
ZendGdata/library/Zend/Gdata/App.php(476): Zend_Http_Client->setUri
('http://gdata.yo...') #3 /web/php/balistik_list_app/app/vendors/
ZendGdata/library/Zend/Gdata.php(203): Zend_Gdata_App-
>performHttpRequest('GET', 'http://gdata.yo...', Array, NULL, NULL,

NULL) #4 /web/php/balistik_list_app/app/vendors/ZendGdata/library/Zend/
Gdata/App.php(610): Zend_Gdata->performHttpRequest('GET', 'http://
gdata.yo...') #5 /web/php/balistik_list_app/app/vendors/ZendGdata/
library/Zend/Gdata/App.php(541): Zend_Gdata_App->get('http://
gdata.yo...') #6 /web/php/balistik_list_app/app/vendors/ZendGdata/
library/Zend/Gdata/App.php(147): Zend_Gdata_App->importUrl('http://
gdata.yo...', 'Zend_Gdata_YouT...') #7 /web/php/balistik_list_app/app/
vendors/ZendGdata/library/Zend/Gdata.php(148): Zend_Gdata_App->getFeed
('http://gdata.yo...', 'Zend_Gdata_YouT...') #8 /web/php/
balistik_list_app/app/vendors/ZendGdata/library/Zend/Gdata/YouTube.php
(171): Zend_Gdata->getFeed('http://gdata.yo...', 'Zend_Gdata_YouT...')
#9 /web/php/balistik_list_app/app/controllers/
item_videos_controller.php(35): Zend_Gdata_YouTube->getVideoFeed(Object
(Zend_Gdata_YouTube_VideoQuery)) #10 /web/php/balistik_list_app/cake/
libs/object.php(114): ItemVideosController->search() #11 /web/php/
balistik_list_app/cake/dispatcher.php(259): Object->dispatchMethod
('search', Array) #12 /web/php/balistik_list_app/cake/dispatcher.php
(213): Dispatcher->_invoke(Object(ItemVideosController), Array) #13 /
web/php/balistik_list_app/app/webroot/index.php(90): Dispatcher-
>dispatch(NULL) #14 {main}
+1  A: 

I just tried on link text

And it seems that racy is not authorized in version 2

<errors xmlns='http://schemas.google.com/g/2005'&gt;
<error>
<domain>GData</domain>
<code>InvalidRequestUriException</code>
<internalReason>Parameter racy not available in version 2</internalReason>  
</error>
</errors>

The request

GET /feeds/api/videos?q=Comedy%2Bdog&safeSearch=none&racy=include
GData-Version: 2

X-GData-Client: ytapi-google-jsdemo

Content-Type: application/atom+xml

Cache-Control: no-cache

Try to remove the racy control or set a different version

GET /feeds/api/videos?q=Comedy%2Bdog&search=none&racy=include

This one is working

stunti
A: 

Does anybody know how to disable these ZEND errors. I really don;t want my visitors to see "Wrong ID..." when interacting with YouTube through API

Kirill
You should pose this is a new question, not as an answer to the question being asked up top.
chipotle_warrior