Last active
May 31, 2019 17:55
-
-
Save stopsatgreen/0354e3caae422c984175 to your computer and use it in GitHub Desktop.
PHP: get JSON, with headers
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 | |
// Because I don’t use PHP often enough to remember it instantly | |
$opts = array( | |
'http'=>array( | |
'method'=>"GET", | |
'header'=>"Accept: application/json" | |
) | |
); | |
$context = stream_context_create($opts); | |
$file = file_get_contents($url, false, $context); | |
$obj = json_decode($file); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment