Created
February 17, 2016 06:46
-
-
Save wpgeek922/e053645fda940ea274c2 to your computer and use it in GitHub Desktop.
Set headers in file_get_contents() for basic authorization
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
$strm_context = stream_context_create(array( | |
'http' => array( | |
'method' => 'GET', // GET,POST (HTTP METHODS) | |
'header' => "Authorization: Bearer ACCESS_TOKEN OR API_KEY\r\n" | |
) | |
)); | |
$result = file_get_contents(SOURCE_URL, false, $strm_context); | |
$data = json_decode($result); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment