- file_get_contents: documentation ( source)
- var_dump: documentation ( source)
- json_decode: documentation ( source)
- stream_context_create: documentation ( source)
<?php
//post url
$url = "https://api.github.com/repos/php/web-bugs/pulls/31";
//set file_get_contents header info
$opts = [
'http' => [
'ignore_errors' => '1',
'user_agent' => "bugs.php.net Pulltracker",
]
];
//initiate file_get_contents
$context = stream_context_create($opts);
//make request
$content = file_get_contents($url, false, $context);
//decode response to array
$responseObject = json_decode($content);
var_dump($responseObject);