-
-
Save elkangaroo/89a4bae00a2d19901ec9be34005b08cc to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
const API_KEY = 'xxx'; | |
$url = 'http://www.giantbomb.com/api/game/3030-4725/?api_key=' . API_KEY . '&field_list=name&format=json'; | |
// using file_get_contents | |
$context = stream_context_create(['http' => ['user_agent' => 'API Test UA']]); | |
$response = file_get_contents($url, false, $context); | |
echo $response; | |
// using curl | |
$curl = curl_init($url); | |
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); | |
curl_setopt($curl, CURLOPT_USERAGENT, 'API Test UA'); | |
$response = curl_exec($curl); | |
curl_close($curl); | |
echo $response; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment