I've been struggling with a curlopt
response for quite some time now and I hope you guys can give me some pointers.
If you please visit the following page: https://niarthgin.com/api/result.php
This will generate a simple response using curlopt
. Here is the code that I have used in order to get these results:
<?php
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://www.bungie.net/Platform/Destiny2/SearchDestinyPlayer/2/Niarthgin/",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => array(
"cache-control: no-cache",
"postman-token: xxxx",
"x-api-key: xxxx"
),
));
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
?>
I want to break down that response but I have no idea how to do it. For example, in that response, you have a MembershipType
a displayName
etc. How can I parse the response individually? Like I know I can parse the response with json.parse()
but that will only parse a given string. I want to be able to parse the response in segments ..
Thanks for reading! :)