Created
July 5, 2015 23:42
-
-
Save duan-li/8b1e538d8c2ea59157b4 to your computer and use it in GitHub Desktop.
send get request with header. Without curl
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
$opts = array( | |
'http'=>array( | |
'method'=>"GET", | |
'header'=>"Content-Type: application/json\r\n" . | |
"X-User-Email: [email protected]\r\n" . | |
"X-Auth-Token: some_auth_token\r\n" | |
) | |
); | |
$context = stream_context_create($opts); | |
// Open the file using the HTTP headers set above | |
$file = file_get_contents('https://your_api_address.com', false, $context); | |
if($file == false) | |
{ | |
http_response_code (404); | |
} | |
else | |
{ | |
http_response_code (200); | |
} | |
die; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment