2

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.

4

1 回答 1

1

我刚刚遇到了同样的问题,这是我的第一个搜索结果。

当您最初将 Xbox API 帐户与 Microsoft 帐户关联时,Xbox API 仅存储帐户电子邮件和 oAuth 令牌,而不是保存您的密码。此令牌仅在有限的时间内有效,因此您需要定期通过 Xbox API 网站登录您的 Microsoft 帐户,为其生成新的 oAuth 令牌。

为此,请转到Xbox API 站点上的个人资料页面,然后单击左下角的“登录 Xbox LIVE”。

输入您的帐户凭据并按“登录 Xbox LIVE”,或单击“使用 oAuth 登录 Xbox LIVE”,它将引导您登录 Xbox 网站。这两种方法本质上应该做同样的事情,因为该站点表示它从不存储或记录您的密码,但如果您偏执,请使用 oAuth 选项。

于 2016-11-13T05:48:01.733 回答