Hey guys, I have some programming experience, but I am sort of new to APIs.
I am trying to get this request:
https://www.haloapi.com/profile/{title}/profiles/{player}/emblem[?size]
Down below is the cosde to use for PHP.
// This sample uses the Apache HTTP client from HTTP Components (http://hc.apache.org/httpcomponents-client-ga/)
require_once ‘HTTP/Request2.php’;
$request = new Http_Request2(‘https://www.haloapi.com/profile/{title}/profiles/{player}/emblem’);
$url = $request->getUrl();
$headers = array(
// Request headers
‘Ocp-Apim-Subscription-Key’ => ‘{subscription key}’,
);
$request->setHeader($headers);
$parameters = array(
// Request parameters
‘size’ => ‘{number}’,
);
$url->setQueryVariables($parameters);
$request->setMethod(HTTP_Request2::METHOD_GET);
// Request body
$request->setBody("{body}");
try
{
$response = $request->send();
echo $response->getBody();
}
catch (HttpException $ex)
{
echo $ex;
}
?>
I filled in the header with this:
$request = new Http_Request2(‘https://www.haloapi.com/profile/{h5}/profiles/{itzhydrogen1}/emblem’);
WHICH WORKS
BUT I get this error message when I go to my page:
{ “statusCode”: 401, “message”: “Access denied due to invalid subscription key. Make sure to provide a valid key for an active subscription.” }
I know I am suppose to insert my Ocp-Apim-Subscription-Key into there, which I did, but its still giving me same error code.
I am inserting my Primary subscription key under “Your Subscriptions” in my profile page. Is this the wrong key or what?