Re: Can Not Load Youtube Page To Get Source Code In Php
Rick Estrada <[email protected]>
| Newsgroups | gmane.comp.web.curl.php |
|---|---|
| Message-ID | <[email protected]> |
as i am in US my server is Canada.. so I will see if a US PROXY makes a difference? i never used it so i see if i can get curl working with it.. yeah if i post the linke in my FF3 address bar http://gdata.youtube.com/feeds/api/videos/dxOpi41Jbys it opens a new tab with a temporary file that contains all the proper info and shows FIREFOX BROWSER. i just can not get the same result from the php page i made and curl? ---------------------------------------- REQUEST HEADER FROM FIREBUG Host: gdata.youtube.com User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.9.0.12) Gecko/2009070611 Firefox/3.0.12 (.NET CLR 3.5.30729) Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8 Accept-Language: en-us,en;q=0.5 Accept-Encoding: gzip,deflate Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7 Keep-Alive: 300 Connection: keep-alive If-Modified-Since: Wed, 29 Jul 2009 07:08:39 GMT REQUEST RESPONSE FROM FIREBUG X-GData-User-Country: US Content-Type: application/atom+xml; charset=UTF-8 Expires: Wed, 29 Jul 2009 16:31:14 GMT Date: Wed, 29 Jul 2009 17:18:51 GMT Cache-Control: private, max-age=300, no-transform Vary: * GData-Version: 1.0 Content-Language: en-US Last-Modified: Wed, 29 Jul 2009 07:08:39 GMT Content-Encoding: gzip X-Content-Type-Options: nosniff Server: GFE/2.0 X-Moz-Is-Feed: 1 On Wed, Jul 29, 2009 at 10:49 AM, Liu Shan Shui <[email protected]> wrote: > 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 > > [email protected] > > "Life would be much easier if I had the source code." - Anonymous > > > > *From:* [email protected] [mailto: > [email protected]] *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'<http://gdata.youtube.com/feeds/api/videos/dxOpi41Jbys%27> > ); > 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 <[email protected]> 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 > > [email protected] > > "Life would be much easier if I had the source code." - Anonymous > > > > _______________________________________________ > http://cool.haxx.se/cgi-bin/mailman/listinfo/curl-and-php > > -- Thanks, Rick Estrada Subfighter Mixed Martial Arts 760-908-9472 http://www.subfighter.tv _______________________________________________ http://cool.haxx.se/cgi-bin/mailman/listinfo/curl-and-php