The Little Guy Posted September 20, 2008 Share Posted September 20, 2008 Why when I use cURL, some sites display: The document has moved here. My code: $url = $_GET['p']; $ch = curl_init(); $timeout = 5; // set to zero for no timeout curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout); $file_contents = curl_exec($ch); curl_close($ch); // display file echo $file_contents; Link to comment https://forums.phpfreaks.com/topic/125033-curl/ Share on other sites More sharing options...
xtopolis Posted September 20, 2008 Share Posted September 20, 2008 <?php curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); ?> It's possible the site has moved and apache is doing a header redirect to the page in question, but you don't have cURL enabled to follow it [off by default I believe]. edit: I remember when I was testing my apache redirect stuff, I didn't even see the page change before I was at my destination because my browser followed so fast. Link to comment https://forums.phpfreaks.com/topic/125033-curl/#findComment-646126 Share on other sites More sharing options...
The Little Guy Posted September 20, 2008 Author Share Posted September 20, 2008 Cool! Link to comment https://forums.phpfreaks.com/topic/125033-curl/#findComment-646128 Share on other sites More sharing options...
The Little Guy Posted September 20, 2008 Author Share Posted September 20, 2008 Some sites, such as facebook say: You are using an incompatible web browser. any way I can fix that? Link to comment https://forums.phpfreaks.com/topic/125033-curl/#findComment-646156 Share on other sites More sharing options...
The Little Guy Posted September 20, 2008 Author Share Posted September 20, 2008 got it! curl_setopt($ch, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']); Link to comment https://forums.phpfreaks.com/topic/125033-curl/#findComment-646165 Share on other sites More sharing options...
The Little Guy Posted September 20, 2008 Author Share Posted September 20, 2008 any way to get around a 400 error? http://dudeel.com/lProxy?p=http://google.com/products?q=flower+girl+dresses&sampleq=1&hl=en Link to comment https://forums.phpfreaks.com/topic/125033-curl/#findComment-646225 Share on other sites More sharing options...
xtopolis Posted September 20, 2008 Share Posted September 20, 2008 I receive no errors from that link. Link to comment https://forums.phpfreaks.com/topic/125033-curl/#findComment-646261 Share on other sites More sharing options...
The Little Guy Posted September 22, 2008 Author Share Posted September 22, 2008 I receive no errors from that link. Cause I fixed it. Link to comment https://forums.phpfreaks.com/topic/125033-curl/#findComment-647390 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.