youtube and 503 errors

3 messages Options
Embed this post
Permalink
breham

youtube and 503 errors

Reply Threaded More More options
Print post
Permalink
Hi,

I've got a script which gets me a video id using gdata and works fine.  I then use the code in an embedded video link.

The problem I've got is every so often (and it can be quite frequent) I get an a 503 response from youtube which results in a fatal error and stops the rest of my page loading.

What I'd like to do is catch the 503 error and then display a message like "Sorry - video not available" instead of the fatal error message.

I guess I can use the zend_http_response but I can't for the life of me figure out how to do it properly.

My code for retrieval of the code is:
require_once 'Zend/Loader.php';
require_once 'Zend/Http/Response.php';
Zend_Loader::loadClass('Zend_Gdata_YouTube');

$yt = new Zend_Gdata_YouTube();
$query = $yt->newVideoQuery();

$query->videoQuery = $trailer;
$query->startIndex = 1;
$query->maxResults = 1;
$query->orderBy = 'relevance';
$query->format = 0;

$videoFeed=$yt->getVideoFeed($query);

foreach ($videoFeed as $videoEntry) {
 
$relatedLinkHref = $videoEntry->getVideoId();

Any ideas gratefully appreciated.

Brett
kwylez

Re: youtube and 503 errors

Reply Threaded More More options
Print post
Permalink
YouTube is blocked at where I work, but I use the following code for Picasa galleries:
try {
  $yt = new Zend_Gdata_YouTube();
  $query = $yt->newVideoQuery();

  $query->videoQuery = $trailer;
  $query->startIndex = 1;
  $query->maxResults = 1;
  $query->orderBy = 'relevance';
  $query->format = 0;

  $videoFeed=$yt->getVideoFeed(
$query);

  foreach ($videoFeed as $videoEntry) {
    $relatedLinkHref = $videoEntry->getVideoId();

  }
catch (Zend_Gdata_App_HttpException $httpexception) {

      print $httpexception->getResponse()->getBody();

}


On Wed, Mar 26, 2008 at 10:29 AM, breham <[hidden email]> wrote:

Hi,

I've got a script which gets me a video id using gdata and works fine.  I
then use the code in an embedded video link.

The problem I've got is every so often (and it can be quite frequent) I get
an a 503 response from youtube which results in a fatal error and stops the
rest of my page loading.

What I'd like to do is catch the 503 error and then display a message like
"Sorry - video not available" instead of the fatal error message.

I guess I can use the zend_http_response but I can't for the life of me
figure out how to do it properly.

My code for retrieval of the code is:
require_once 'Zend/Loader.php';
require_once 'Zend/Http/Response.php';
Zend_Loader::loadClass('Zend_Gdata_YouTube');

$yt = new Zend_Gdata_YouTube();
$query = $yt->newVideoQuery();

$query->videoQuery = $trailer;
$query->startIndex = 1;
$query->maxResults = 1;
$query->orderBy = 'relevance';
$query->format = 0;

$videoFeed=$yt->getVideoFeed($query);

foreach ($videoFeed as $videoEntry) {

$relatedLinkHref = $videoEntry->getVideoId();

Any ideas gratefully appreciated.

Brett

--
View this message in context: http://www.nabble.com/youtube-and-503-errors-tp16303001p16303001.html
Sent from the Zend gdata mailing list archive at Nabble.com.




--
Cory Wiles
[hidden email]
http://www.corywiles.com
http://www.400mtogo.com
Ryan Boyd-3

Re: youtube and 503 errors

Reply Threaded More More options
Print post
Permalink
Hi Brett,

503s can happen now and then and are meant to be temporary errors--- but they shouldn't happen often.

Cory's mechanism is the best way to handle this in live code-- catching the exception and displaying an appropriate error message.

For debugging purposes, ZF 1.5+ also supports something like the following:
$yt->enableRequestDebugLogging('/tmp/yt_requests.log');

That'll log all HTTP requests/responses to a log file (works fine so long as you're not using a proxy server).

If you continue to get the 503 errors, please log what you can and send me as much info as you can (times, exact URLs, your IP address,, etc are helpful)
and we should hopefully be able to look into it more.

Cheers,
-Ryan


On Wed, Mar 26, 2008 at 1:42 PM, Cory D. Wiles <[hidden email]> wrote:
YouTube is blocked at where I work, but I use the following code for Picasa galleries:
try {
  $yt = new Zend_Gdata_YouTube();
  $query = $yt->newVideoQuery();

  $query->videoQuery = $trailer;
  $query->startIndex = 1;
  $query->maxResults = 1;
  $query->orderBy = 'relevance';
  $query->format = 0;

  $videoFeed=$yt->getVideoFeed(
$query);

  foreach ($videoFeed as $videoEntry) {
    $relatedLinkHref = $videoEntry->getVideoId();

  }
catch (Zend_Gdata_App_HttpException $httpexception) {

      print $httpexception->getResponse()->getBody();

}


On Wed, Mar 26, 2008 at 10:29 AM, breham <[hidden email]> wrote:

Hi,

I've got a script which gets me a video id using gdata and works fine.  I
then use the code in an embedded video link.

The problem I've got is every so often (and it can be quite frequent) I get
an a 503 response from youtube which results in a fatal error and stops the
rest of my page loading.

What I'd like to do is catch the 503 error and then display a message like
"Sorry - video not available" instead of the fatal error message.

I guess I can use the zend_http_response but I can't for the life of me
figure out how to do it properly.

My code for retrieval of the code is:
require_once 'Zend/Loader.php';
require_once 'Zend/Http/Response.php';
Zend_Loader::loadClass('Zend_Gdata_YouTube');

$yt = new Zend_Gdata_YouTube();
$query = $yt->newVideoQuery();

$query->videoQuery = $trailer;
$query->startIndex = 1;
$query->maxResults = 1;
$query->orderBy = 'relevance';
$query->format = 0;

$videoFeed=$yt->getVideoFeed($query);

foreach ($videoFeed as $videoEntry) {

$relatedLinkHref = $videoEntry->getVideoId();

Any ideas gratefully appreciated.

Brett

--
View this message in context: http://www.nabble.com/youtube-and-503-errors-tp16303001p16303001.html
Sent from the Zend gdata mailing list archive at Nabble.com.




--
Cory Wiles
[hidden email]
http://www.corywiles.com
http://www.400mtogo.com