Hello i'm using unofficial x-box one api for sending messages over x-box live accounts.Here is my code sample and error(Problem).
Code:
<?php
$arr = array('to' => array("gamoneybcn"), 'message' => "This is an Test Test example message sent via XboxAPI.");
$post = json_encode($arr);
$proServiceUrl = "https://xboxapi.com/v2/messages/";
$contentsType = 'application/json';
$methods = 'POST';
$auths = 'X-AUTH: XXXX';
$profilesCurl = curl_init();
curl_setopt($profilesCurl, CURLOPT_URL, $proServiceUrl);
curl_setopt($profilesCurl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($profilesCurl, CURLOPT_POSTFIELDS, $post);
curl_setopt($profilesCurl, CURLINFO_HEADER_OUT, true);
curl_setopt($profilesCurl, CURLOPT_HTTPHEADER, Array('Content-type:'.$contentsType.';auth='.$auths));
curl_setopt($profilesCurl, CURLOPT_HTTPHEADER, Array($auths));
$profilesJson = curl_exec($profilesCurl);
echo "<pre>";
print_r($profilesJson);
exit;
?>
Problem:
If i'm not logged in my x-box one unofficial developer account my api's not working and getting error code like below.
Error:
{"success":false,"error_code":401,"error_message":"A fresh login is required to gain a new token from Microsoft"}.
Note:
As soon as i logged in my x-box one api developer account the api will run.i have also try to first make curl authentication but i dont know is it possible after curl authentication? if is it possible by making first curl authentication so please helping me to solve out this problem as soon as possible.a big thanks in advance.