If you want to play around with the PHP library, you can get up and running quickly with the PHP Connect Sample. This sample will start you with a little Laravel project that helps you with registration, authentication, and making a simple call to the service.
You can install the PHP SDK with Composer.
{
"require": {
"microsoft/microsoft-graph": "1.0.*"
}
}
Register your application to use the Microsoft Graph API by using one of the following supported authentication portals:
- Microsoft Application Registration Portal (Recommended): Register a new application that authenticates using the v2.0 authentication endpoint. This endpoint authenticates both personal (Microsoft) and work or school (Azure Active Directory) accounts.
- Microsoft Azure Active Directory: Register a new application in your tenant's Active Directory to support work or school users for your tenant, or multiple tenants.
The Microsoft Graph SDK for PHP does not include any default authentication implementations. Instead, you can authenticate with the library of your choice, or against the OAuth endpoint directly.
To connect with Oauth2, see the PHP Connect Sample.
The following is an example that shows how to call Microsoft Graph.
use Microsoft\Graph\Graph;
use Microsoft\Graph\Model;
class UsageExample
{
public function run()
{
$accessToken = 'xxx';
$graph = new Graph();
$graph->setAccessToken($accessToken);
$user = $graph->createRequest("GET", "/me")
->setReturnType(Model\User::class)
->execute();
echo "Hello, I am $user->getGivenName() ";
}
}
Run
vendor/bin/phpunit --exclude-group functional
from the base directory.
The set of functional tests are meant to be run against a test account. Currently, the tests to do not restore state of the account.
View or log issues on the Issues tab in the repo.
Copyright (c) Microsoft Corporation. All Rights Reserved. Licensed under the MIT license.