How to Get a Webpage's contents without CURL ?

Posted by Arsheep on Stack Overflow See other posts from Stack Overflow or by Arsheep
Published on 2010-05-31T20:40:25Z Indexed on 2010/05/31 20:43 UTC
Read the original article Hit count: 298

Filed under:
|
|

I need to get webpage's content ,I cant use Curl as it is not enabled.I tried the below code But it is not working.

$opts = array(
  'http'=>array(
    'method'=>"GET",
    'header'=>"Accept-language: en\r\n" .
              "Cookie: foo=bar\r\n"
  )
);

$context = stream_context_create($opts);   

$fp = fopen($_GET['url'], 'r', false, $context);
if($fp)
fpassthru($fp);
fclose($fp);
exit;

The code produce an error

Warning: fopen(http://www.google.com/search?&q=site:www.myspace.com+-intitle:MySpaceTV+%22Todd Terje%22) [function.fopen]: failed to open stream: HTTP request failed! HTTP/1.0 400 Bad Request 

© Stack Overflow or respective owner

Related posts about php

Related posts about curl