Microsoft Graph SDK PHP:CreateRequest无法正常工作

时间:2017-11-02 16:45:12

标签: php api

我正在尝试使用Microsoft Graph SDK PHP。

我有一个带index.php和vendor的简单目录(完全按照相关github项目的要求创建:https://github.com/microsoftgraph/msgraph-sdk-php)。

我的index.php文件如下:

require_once("./vendor/autoload.php");

use Microsoft\Graph\Graph;
use Microsoft\Graph\Model;

$accessToken = 'xxx'; // Here I would insert the access token

$graph = new Graph();
$graph->setAccessToken($accessToken);

// Code that is not working:
$user = $graph->createRequest("GET", "/me")
   ->setReturnType(Model\User::class)
   ->execute();

echo "Hello, I am $user->getGivenName() ";

问题; createRequest 无效(php文件停止执行)...我不知道为什么,因为我刚刚复制了Github项目的示例代码。

我做错了什么?

感谢您的帮助:)

1 个答案:

答案 0 :(得分:0)

回答:显然,访问令牌中的任何错误都会导致崩溃。因此代码正在运作。

相关问题