Skip to content

Instantly share code, notes, and snippets.

@xqus
Created February 13, 2011 18:22
Show Gist options
  • Save xqus/824914 to your computer and use it in GitHub Desktop.
Save xqus/824914 to your computer and use it in GitHub Desktop.
<?php
/* Set up array with options for the context used by file_get_contents(). */
$opts = array(
'http'=>array(
'method'=>"GET",
'header'=>"Accept-language: en\r\n" .
"User-Agent: phpSec (http://phpsec.xqus.com)\r\n"
)
);
/* Create context. Allowing us to specify User-Agent. */
$context = stream_context_create($opts);
/* Get data from remote server. */
$data = file_get_contents('http://example.com', null, $context);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment