All Projects → microsoftgraph → Msgraph Sdk Php

microsoftgraph / Msgraph Sdk Php

Licence: other
Microsoft Graph Library for PHP.

Labels

Projects that are alternatives of or similar to Msgraph Sdk Php

Dynamixelsdk
ROBOTIS Dynamixel SDK (Protocol1.0/2.0)
Stars: ✭ 266 (-11.92%)
Mutual labels:  sdk
Assistants Pi
Headless Google Assistant and Alexa on Raspberry Pi
Stars: ✭ 280 (-7.28%)
Mutual labels:  sdk
Ble examples
Additional examples to compliment TI's Bluetooth Low Energy Stack offerings.
Stars: ✭ 289 (-4.3%)
Mutual labels:  sdk
Artoolkitx
artoolkitX
Stars: ✭ 272 (-9.93%)
Mutual labels:  sdk
Dropbox Sdk Dotnet
The Official Dropbox API V2 SDK for .NET
Stars: ✭ 274 (-9.27%)
Mutual labels:  sdk
Qiskit Terra
Qiskit is an open-source SDK for working with quantum computers at the level of extended quantum circuits, operators, and algorithms.
Stars: ✭ 3,177 (+951.99%)
Mutual labels:  sdk
Postman Collection
Javascript module that allows a developer to work with Postman Collections
Stars: ✭ 265 (-12.25%)
Mutual labels:  sdk
Mixpanel Swift
Official iOS (Swift) Tracking Library for Mixpanel Analytics
Stars: ✭ 294 (-2.65%)
Mutual labels:  sdk
Phnt
Native API header files for the Process Hacker project.
Stars: ✭ 276 (-8.61%)
Mutual labels:  sdk
Python Sdk
百度AI开放平台 Python SDK
Stars: ✭ 285 (-5.63%)
Mutual labels:  sdk
Cognitive Face Android
Cognitive Services Face client library for Android.
Stars: ✭ 273 (-9.6%)
Mutual labels:  sdk
Parse Sdk Dotnet
Parse SDK for .NET, Xamarin, Unity.
Stars: ✭ 272 (-9.93%)
Mutual labels:  sdk
Alan Sdk Android
Alan AI Android SDK adds a voice assistant or chatbot to your app. Supports Java, Kotlin.
Stars: ✭ 278 (-7.95%)
Mutual labels:  sdk
Skylinkjs
SkylinkJS Javascript WebRTC SDK
Stars: ✭ 269 (-10.93%)
Mutual labels:  sdk
Consul Php Sdk
PHP Consul SDK
Stars: ✭ 288 (-4.64%)
Mutual labels:  sdk
Stream Chat Flutter
Stream Chat official Flutter SDK. Build your own chat experience using Dart and Flutter.
Stars: ✭ 220 (-27.15%)
Mutual labels:  sdk
Easybluetooth
一款iOS BLE蓝牙调试工具,非常简单容易,也可以作为一个蓝牙库,快速集成和开发。 可以两步搞定蓝牙开发操作。 第一步连接设备,第二步特征读写数据。
Stars: ✭ 282 (-6.62%)
Mutual labels:  sdk
Janephp
🌱 Jane is a set of libraries to generate Models & API Clients based on JSON Schema / OpenAPI specs
Stars: ✭ 300 (-0.66%)
Mutual labels:  sdk
Alan Sdk Ionic
Alan AI Ionic SDK adds a voice assistant or chatbot to your app. Supports React, Angular.
Stars: ✭ 287 (-4.97%)
Mutual labels:  sdk
Gpmf Parser
Parser for GPMF™ formatted telemetry data used within GoPro® cameras.
Stars: ✭ 282 (-6.62%)
Mutual labels:  sdk

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, either run composer require microsoft/microsoft-graph, or edit your composer.json file:

{
    "require": {
        "microsoft/microsoft-graph": "^1.20"
    }
}

Get started with Microsoft Graph

Register your application

Register your application to use the Microsoft Graph API using Microsoft Azure Active Directory 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. The thephpleague/oauth2-client library will handle the OAuth2 flow for you and provide a usable token for querying the Graph.

To authenticate as an application you can use the Guzzle HTTP client, which comes preinstalled with this library, for example like this:

$guzzle = new \GuzzleHttp\Client();
$url = 'https://login.microsoftonline.com/' . $tenantId . '/oauth2/token?api-version=1.0';
$token = json_decode($guzzle->post($url, [
    'form_params' => [
        'client_id' => $clientId,
        'client_secret' => $clientSecret,
        'resource' => 'https://graph.microsoft.com/',
        'grant_type' => 'client_credentials',
    ],
])->getBody()->getContents());
$accessToken = $token->access_token;

For an integrated example on how to use Oauth2 in a Laravel application and use the Graph, see the PHP Connect Sample.

Call Microsoft Graph using the v1.0 endpoint and models

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

Call Microsoft Graph using the beta endpoint and models

The following is an example that shows how to call Microsoft Graph.

use Microsoft\Graph\Graph;
use Beta\Microsoft\Graph\Model as BetaModel;

class UsageExample
{
    public function run()
    {
        $accessToken = 'xxx';

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

        $user = $graph->setApiVersion("beta")
                      ->createRequest("GET", "/me")
                      ->setReturnType(BetaModel\User::class)
                      ->execute();

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

Develop

Debug

You can use the library with a proxy such as Fiddler or Charles Proxy to debug requests and responses as they come across the wire. Set the proxy port on the Graph object like this:

$graph->setProxyPort("localhost:8888");

Then, open your proxy client to view the requests & responses sent using the library.

Screenshot of Fiddler /me/sendmail request and response

This is especially helpful when the library does not return the results you expected to determine whether there are bugs in the API or this SDK. Therefore, you may be asked to provide this information when attempting to triage an issue you file.

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.

Debug tests on Windows

This SDK has an XDebug run configuration that attaches the debugger to VS Code so that you can debug tests.

  1. Install the PHP Debug extension into Visual Studio Code.
  2. From the root of this repo, using PowerShell, run php .\tests\GetPhpInfo.php | clip from the repo root. This will copy PHP configuration information into the clipboard which we will use in the next step.
  3. Paste your clipboard into the XDebug Installation Wizard and select Analyse my phpinfo() output.
  4. Follow the generated instructions for installing XDebug. Note that the /ext directory is located in your PHP directory.
  5. Add the following info to your php.ini file:
[XDebug]
xdebug.remote_enable = 1
xdebug.remote_autostart = 1

Now you can hit a Visual Studio Code breakpoint in a test. Try this:

  1. Add a breakpoint to testGetCalendarView in .\tests\Functional\EventTest.php.
  2. Run the Listen for XDebug configuration in VS Code.
  3. Run .\vendor\bin\phpunit --filter testGetCalendarView from the PowerShell terminal to run the test and hit the breakpoint.

Documentation and resources

Issues

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

Contribute

Please read our Contributing guidelines carefully for advice on how to contribute to this repo.

Copyright and license

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

This project has adopted the Microsoft Open Source Code of Conduct. For more information see the Code of Conduct FAQ or contact [email protected] with any additional questions or comments.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].