Curl: Object Moved Error..??

x5g7j9l3x

Junior Member
Joined
Feb 20, 2009
Messages
127
Reaction score
1
I made a PHP curl page that works ok, but with some URLs it gives me an "Object Moved, This document may be found here" with a link to go to the site the original URL is forwarding to..
so my question is how can i make the php page get that new URL & then curl it..??
 
use:
PHP:
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
in your curl function :)
 
i already have that in my code, but it don't seem to be working though..??

Code:
<?php
$Link = $_SERVER['QUERY_STRING'];
$uri = parse_url($Link);
$base = "http://".$uri[host]."";

    echo geturl($Link, $base);

    function geturl($url, $referer) { 

        $headers[] = 'Accept: image/png, image/gif, image/x-bitmap, image/jpeg, image/pjpeg'; 
        $headers[] = 'Connection: Keep-Alive'; 
        $headers[] = 'Content-type: application/x-www-form-urlencoded;charset=UTF-8'; 
        $UserAgent = 'Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.0)'; 

        $process = curl_init($url); 
        curl_setopt($process, CURLOPT_HTTPHEADER, $headers); 
        curl_setopt($process, CURLOPT_HEADER, 0); 
        curl_setopt($process, CURLOPT_USERAGENT, $UserAgent);
        curl_setopt($process, CURLOPT_REFERER, $referer);
        curl_setopt($process, CURLOPT_TIMEOUT, 60); 
        curl_setopt($process, CURLOPT_RETURNTRANSFER, 1); 
        curl_setopt($process, CURLOPT_FOLLOWLOCATION, 1); 

        $return = curl_exec($process);
        curl_close($process); 

        return $return; 
    } 

?>
 
shot me PM with site you are trying use in this script....
maybe you miss something
 
I think your url require redirect You should use proper url for it
 
CURLOPT_FOLLOWLOCATION cannot be activated when in safe_mode or an open_basedir is set.

If you have access to your php configuration (php.ini) set :
Code:
open_basedir none
safe_mode off

Hope that helps!
 
i have a free web hosting account ,where is this (php.ini) file located at..??
 
Back
Top