Collectives™ on Stack Overflow

Find centralized, trusted content and collaborate around the technologies you use most.

Learn more about Collectives

Teams

Q&A for work

Connect and share knowledge within a single location that is structured and easy to search.

Learn more about Teams

This url

' http://profile.myspace.com/index.cfm?fuseaction=user.viewProfile&friendID=39726387 '

works perfectly well in a browser but cURL return's error 3 (malformed url).

Any ideas on a work around?

EDIT:

cURL code:

function get_web_page( $url )
    $options = array(
        CURLOPT_RETURNTRANSFER => true,     // return web page
        CURLOPT_HEADER         => false,    // don't return headers
        CURLOPT_FOLLOWLOCATION => true,     // follow redirects
        CURLOPT_ENCODING       => "",       // handle all encodings
        CURLOPT_USERAGENT      => "spider", // who am i
        CURLOPT_AUTOREFERER    => true,     // set referer on redirect
        CURLOPT_CONNECTTIMEOUT => 120,      // timeout on connect
        CURLOPT_TIMEOUT        => 120,      // timeout on response
        CURLOPT_MAXREDIRS      => 10,       // stop after 10 redirects
    $ch      = curl_init( $url );
    curl_setopt_array( $ch, $options );
    $content = curl_exec( $ch );
    $err     = curl_errno( $ch );
    $errmsg  = curl_error( $ch );
    $header  = curl_getinfo( $ch );
    curl_close( $ch );
    if (!$errmsg =='') {die($err.':'.$errmsg);} 
    return $content;
                My problem was, that i passed the wrong variable to curl... It wasn't an URI. Posted this comment, just in case someone else spent 2 hours searching for what's wrong just to find out that rookie mistake. :)
– Jo Smo
                Oct 22, 2016 at 9:03

I get the output of the page when running

curl http://profile.myspace.com/index.cfm?fuseaction=user.viewProfile&friendID=39726387

This also works for me:

$ch = curl_init('http://profile.myspace.com/index.cfm?fuseaction=user.viewProfile&friendID=39726387');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$out = curl_exec($ch);
curl_close($ch);
echo $out;

Edit: Just tried your code posted and it works fine for me. Perhaps the string you are passing into get_web_page() is wrong?

Thanks for contributing an answer to Stack Overflow!

  • Please be sure to answer the question. Provide details and share your research!

But avoid

  • Asking for help, clarification, or responding to other answers.
  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.