Office365 API返回:受众群体声明值的主机名组件' https://graph.microsoft.com'是无效的

时间:2016-01-26 23:27:27

标签: office365api

我似乎无法解决这个问题。我发现一些问题接近这个问题,说配置是问题,但是,我能够使用发送邮件功能。我刚刚开始学习Office365 API,非常感谢您的帮助!

以下是摘录:

$curl = curl_init(
$headers = array(
    'Authorization: Bearer ' . $_SESSION['access_token'],
    'Content-Type: application/json;' .
    'odata.metadata=minimal;' .
    'odata.streaming=true'
);

curl_setopt_array(
    $curl,
    array(
        CURLOPT_RETURNTRANSFER => 1,
        CURLOPT_URL => 'https://outlook.office.com/api/v2.0/me/MailFolders/inbox/messages/',
        CURLOPT_HTTPHEADER => $headers,
        CURLOPT_VERBOSE => 1,
        CURLOPT_HEADER => 1
    )
);

// The following curl options can be used in development to debug the code.
// Option to disable certificate verification. Do not use on production env.
// curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
// Option to set a proxy for curl to use.
// Useful if you want to review traffic with a tool like Fiddler.
// curl_setopt($curl, CURLOPT_PROXY, '127.0.0.1:8888');

// Enable error reporting on curl
//curl_setopt($curl, CURLOPT_FAILONERROR, true);

// Send the request & save response to a variable
$response = curl_exec($curl);
// Check for errors
if (curl_errno($curl)) {
    print_r(curl_error($curl));
    throw new \RuntimeException(curl_error($curl));
}

echo '<pre>';
print_r($response);

// Close request and clear some resources
curl_close($curl);

返回:

x-ms-diagnostics: 2000003;reason="The hostname component of the audience claim value 'https://graph.microsoft.com' is invalid";error_category="invalid_resource"

如果是配置(Azure AD),那么我需要检查什么?如果这有帮助,我已授予Azure AD中Microsoft Graph的所有权限。

1 个答案:

答案 0 :(得分:2)

当您尝试访问> df[c(1:25),] [,1] 2014-01-01 01:00:00 4.67 2014-01-01 02:00:00 4.78 2014-01-01 03:00:00 4.87 2014-01-01 04:00:00 4.61 2014-01-01 05:00:00 4.58 2014-01-01 06:00:00 4.47 2014-01-01 07:00:00 4.66 2014-01-01 08:00:00 4.46 2014-01-01 09:00:00 4.57 2014-01-01 10:00:00 4.87 2014-01-01 11:00:00 4.57 2014-01-01 12:00:00 4.67 2014-01-01 13:00:00 5.52 2014-01-01 14:00:00 6.42 2014-01-01 15:00:00 6.79 2014-01-01 16:00:00 6.50 2014-01-01 17:00:00 5.81 2014-01-01 18:00:00 5.65 2014-01-01 19:00:00 6.25 2014-01-01 20:00:00 5.79 2014-01-01 21:00:00 5.84 2014-01-01 22:00:00 6.06 2014-01-01 23:00:00 4.74 2014-01-02 01:00:00 4.66 2014-01-02 02:00:00 5.59 时,您指定的访问令牌适用于https://graph.microsoft.com

尝试使用https://outlook.office.com代替https://graph.microsoft.com/v1.0/me/messages