Skip to content
This repository has been archived by the owner on Nov 3, 2022. It is now read-only.

WeConnectArchive/msgraph-sdk-php

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

90 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Get started with the Microsoft Graph SDK for PHP

Build Status Latest Stable Version

Get started with the PHP Connect Sample

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.

Install the SDK

You can install the PHP SDK with Composer.

{
    "require": {
        "microsoft/microsoft-graph": "1.0.*"
    }
}

Get started with Microsoft Graph

Register your application

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.

Authenticate with the Microsoft Graph service

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.

Call Microsoft Graph

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() ";
    }
}

Develop

Run Tests

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.

Documentation and resources

Issues

View or log issues on the Issues tab in the repo.

Copyright and license

Copyright (c) Microsoft Corporation. All Rights Reserved. Licensed under the MIT license.

About

Microsoft Graph Library for PHP.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • PHP 100.0%