I'm trying to authenticate with xboxapi.com via curl in PHP and i keep getting unauthorized 401.
To connect to the API we need an Authentication header. This is sent as X-AUTH
https://xboxapi.com/documentation
I'm using the following code for authentication:
$headerArr = array();
$headerArr[] = "X-AUTH: here i put my api key";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://xboxapi.com/v2/accountXuid');
curl_setopt($ch, CURLOPT_HTTPHEADER, $headerArr);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$result = curl_exec($ch);
I can't figure out what's wrong with the code...
The second problem i'm having is when i'm trying to get data from the api (i'm logged in to check)
I'm using:
<script>
$(document).ready(function() {
$.ajax({
url: 'https://xboxapi.com/v2/accountXuid',
dataType: 'jsonp',
jsonpCallback: 'callback',
jsonp: false,
});
});
</script>
and in firebug console I'm getting:
SyntaxError: missing ; before statement.
OK i get it, it's JSON and not JSONP but in net response (in firebug) i see the JSON. Is there a way to load JSON and not JSONP? How can i see the results on screen?
Any other solution will be welcomed here! Thank you.