1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Curl: Object Moved Error..??

Discussion in 'PHP & Perl' started by x5g7j9l3x, Oct 5, 2009.

  1. x5g7j9l3x

    x5g7j9l3x Junior Member

    Joined:
    Feb 20, 2009
    Messages:
    127
    Likes Received:
    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..??
     
  2. cyklotrial

    cyklotrial Regular Member

    Joined:
    Oct 13, 2008
    Messages:
    248
    Likes Received:
    82
    Location:
    Wonderland
    use:
    PHP:
    curl_setopt($chCURLOPT_FOLLOWLOCATION1);
    in your curl function :)
     
  3. x5g7j9l3x

    x5g7j9l3x Junior Member

    Joined:
    Feb 20, 2009
    Messages:
    127
    Likes Received:
    1
    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; 
        } 
    
    ?>
    
     
  4. cyklotrial

    cyklotrial Regular Member

    Joined:
    Oct 13, 2008
    Messages:
    248
    Likes Received:
    82
    Location:
    Wonderland
    shot me PM with site you are trying use in this script....
    maybe you miss something
     
  5. embersion

    embersion BANNED BANNED

    Joined:
    Jun 13, 2009
    Messages:
    430
    Likes Received:
    15
    I think your url require redirect You should use proper url for it
     
  6. zone69

    zone69 Junior Member

    Joined:
    Nov 24, 2008
    Messages:
    196
    Likes Received:
    1,290
    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!
     
  7. x5g7j9l3x

    x5g7j9l3x Junior Member

    Joined:
    Feb 20, 2009
    Messages:
    127
    Likes Received:
    1
    i have a free web hosting account ,where is this (php.ini) file located at..??