![]() |
How to file_get_contents a gzip page ? - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23) +--- Thread: How to file_get_contents a gzip page ? (/showthread.php?tid=16093) |
How to file_get_contents a gzip page ? - El Forum - 02-24-2009 [eluser]Benjamin David[/eluser] Hi ! I'm trying to get the content of a page that has gzip header compression. When I file_get_contents the page, the result is compressed and I can't find a way to get the original content, uncompressed. I've tried the gzdeflate and gzuncompress php 5 function and it didn't work. I haven't tried the gzdecode function as it comes with PHP 6 and my host hasn't it yet. The page I'm trying to get content from is there : http://ax.phobos.apple.com.edgesuite.net/WebObjects/MZStoreServices.woa/wa/wsSearch?term=jack+johnson&limit=1 And it's killing me because I can make it work in Javascript with Ajax requests because the browser automaticaly uncompresses the whole thing but not with PHP... Too bad ! Thanks for helping ! How to file_get_contents a gzip page ? - El Forum - 02-24-2009 [eluser]xwero[/eluser] How do you read the content now? How to file_get_contents a gzip page ? - El Forum - 02-24-2009 [eluser]pistolPete[/eluser] This problem is described here plus a workaround is suggested: http://bugs.php.net/bug.php?id=22967 But there are other possibilities: Try to send a HTTP request without Code: Accept-Encoding: gzip Alternatively you could use cURL: Code: curl_setopt($handle,CURLOPT_ENCODING , 'gzip'); Or use one of the user contributed gzdecode() functions here: http://php.net/gzencode How to file_get_contents a gzip page ? - El Forum - 02-24-2009 [eluser]Benjamin David[/eluser] Thanks for your answer ! It's giving me hope ![]() I'm gonna test them and I'll hopefully write back the final word so it can help others that are trying to use Apple API. How to file_get_contents a gzip page ? - El Forum - 02-24-2009 [eluser]Benjamin David[/eluser] The user contributed gzdecode() function you were talking about works perfectly ! Thanks a lot pistolPete ! So here's the function I used to get decode a gziped string (found there : http://php.net/gzencode) : Code: <?php How to file_get_contents a gzip page ? - El Forum - 03-08-2010 [eluser]digitalpbk[/eluser] Thanks for this information, I had a problem similarly while using file_get_contents which returned me gzip contents and I had to unzip. See more details file_get_contents gzip uncompress |