file_get_contents with gists

Doing a regular file_get_contents with gist API will return forbidden to allow the connection the user agent should be passed with the request.

$url = 'https://api.github.com/users/username/gists';
$options  = array('http' => array('user_agent'=> $_SERVER['HTTP_USER_AGENT']));
$context  = stream_context_create($options);
$response = file_get_contents($url, false, $context);
Share on facebook
Facebook
Share on twitter
Twitter
Share on linkedin
LinkedIn