curl-and-php
RE: Can Not Load Youtube Page To Get Source Code In Php
Date: Thu, 30 Jul 2009 01:49:03 +0800
Hi Rick,
Once again, it works fine here:
http://phpieceofcake.com/?66888746
I'm guessing that YouTube is blocking all non-US IPs from accessing *that
video* due to copyright issues (phpieceofcake.com and
sandbox.phpieceofcake.com are hosted on US servers; that's why it's
working). There's nothing wrong with cURL and your script, and as you have
said, your script works fine with other YouTube videos. So if you need your
script to work for that particular video and other copyright-restricted
videos, you'll have to either host it on a US server or send the request
through a US proxy.
As for how to use a proxy in cURL.there's quite a lot of information out
there:
http://lmgtfy.com/?q=How+to+use+cURL+with+a+proxy%3F
With regards,
Liu Shan Shui
me_at_lx.sg
"Life would be much easier if I had the source code." - Anonymous
From: curl-and-php-bounces_at_cool.haxx.se
[mailto:curl-and-php-bounces_at_cool.haxx.se] On Behalf Of Rick Estrada
Sent: Thursday, July 30, 2009 12:47 AM
To: curl with PHP
Subject: Re: Can Not Load Youtube Page To Get Source Code In Php
well i was trying to load the YOUTUBE API to get the XML and the DATA about
the Video
http://gdata.youtube.com/feeds/api/videos/dxOpi41Jbys
which it downloads in my browser fine but when i put on my server in the php
file it does not work and it returns me a different page...
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,
'http://gdata.youtube.com/feeds/api/videos/dxOpi41Jbys');
curl_setopt($ch, CURLOPT_HEADER, 1);
curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows; U; Windows NT
5.1; en-US; rv:1.8.1.1) Gecko/20061204 Firefox/2.0.0.1');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$google_string = curl_exec($ch);
curl_close($ch);
$google_string = utf8_encode($google_string);
print_r($google_string);
as i tested our page and it works correctly?
is there a way bypass IP-range restriction and see if thats the problem.
Thats would be weird as i can grab other videoid's no proble
i never tried the PROXY with curl so can that help test and see if that the
issue or something i can see in the headers or something?
On Wed, Jul 29, 2009 at 4:52 AM, Liu Shan Shui <me_at_lx.sg> wrote:
Hi Rick,
Your code works fine. It's probably some IP-range restriction for that video
on Youtube's side that's blocking your server.
http://phpieceofcake.com/?76868110
With regards,
Liu Shan Shui
me_at_lx.sg
"Life would be much easier if I had the source code." - Anonymous
_______________________________________________
http://cool.haxx.se/cgi-bin/mailman/listinfo/curl-and-php
Received on 2009-07-29