Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/azure/12.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
PHP:如何在GET/POST调用中将承载令牌传递给Azure API?_Php_Azure_Active Directory_Http Headers_Access Token - Fatal编程技术网

PHP:如何在GET/POST调用中将承载令牌传递给Azure API?

PHP:如何在GET/POST调用中将承载令牌传递给Azure API?,php,azure,active-directory,http-headers,access-token,Php,Azure,Active Directory,Http Headers,Access Token,我打电话到https://login.windows.net/common/oauth2/token并收到类似的回复: { "token_type": "Bearer", "scope": "Directory.Read.All User.Read", "expires_in": "3600", "ext_expires_in": "0", "resource": "https://graph.windows.net", "access_token

我打电话到
https://login.windows.net/common/oauth2/token
并收到类似的回复:

{
    "token_type": "Bearer",
    "scope": "Directory.Read.All User.Read",
    "expires_in": "3600",
    "ext_expires_in": "0",
    "resource": "https://graph.windows.net",
    "access_token": {{really_long_token_1}},
    "refresh_token": {{really_long_token_2}},
    "id_token": {{really_long_token_3}}
}
我有一个托管在HostGator上的网站,它试图访问我在Azure上找到的API

对Azure上托管的my API的
GET
调用的正确形式是什么?以下是我目前掌握的情况:

$url = 'https://myappservice.azurewebsites.net/api/getValues';

$options = array(
    'http' => array(
        'header' => array(
            'x-ms-version: 2017-06-02',
            'Authorization: Bearer {{really_long_token_1}}'
         ),
        'method' => 'GET'
     )
);

$context = stream_context_create($options);
$result = file_get_contents($url, false, $context);

$var_dump($result);

我在进行此呼叫时,最终收到
500
服务器错误。

500
内部错误,表示服务器遇到意外情况,无法满足请求

它不应与身份验证/授权相关,请检查是否存在导致此异常的代码。或者,您可以使用非常简单的代码示例替换代码,而不需要任何复杂的业务逻辑,只需返回值即可