Reputation: 33
I am trying to use the Microsoft Graph SDK PHP.
I have simple directory with index.php and vendor (created exactly as requested in the related github project: https://github.com/microsoftgraph/msgraph-sdk-php).
My index.php file looks like:
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() ";
The issue; createRequest is not working (the php file stop to be executed)... And I have no idea why, as I have just copied the sample code of the Github project.
What do I do wrong?
Thank you for your help :)
Upvotes: 1
Views: 939
Reputation: 33
Answer: Apparently, any error in the access token will always make it crash. The code is therefore working.
Upvotes: 1