Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bahadirdogru/7291357eb4c690fa6daba863f27cad5b to your computer and use it in GitHub Desktop.
Save bahadirdogru/7291357eb4c690fa6daba863f27cad5b to your computer and use it in GitHub Desktop.
PHP: set user agent using file_get_contents()
<?php
$options = array('http' => array('user_agent' => 'custom user agent string'));
$context = stream_context_create($options);
$response = file_get_contents('http://domain/path/to/uri', false, $context);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment