{"id":8469,"date":"2017-05-24T17:30:27","date_gmt":"2017-05-24T08:30:27","guid":{"rendered":"https:\/\/www.ka-net.org\/blog\/?p=8469"},"modified":"2017-05-24T17:30:27","modified_gmt":"2017-05-24T08:30:27","slug":"microsoft-graph-sdk-for-php%e3%82%92%e4%bd%bf%e3%81%a3%e3%81%9fapi%e3%81%ae%e5%91%bc%e3%81%b3%e5%87%ba%e3%81%97%e3%82%b5%e3%83%b3%e3%83%97%e3%83%ab","status":"publish","type":"post","link":"https:\/\/www.ka-net.org\/blog\/?p=8469","title":{"rendered":"Microsoft Graph SDK for PHP\u3092\u4f7f\u3063\u305fAPI\u306e\u547c\u3073\u51fa\u3057\u30b5\u30f3\u30d7\u30eb"},"content":{"rendered":"<p>\u77e5\u3089\u306a\u3044\u9593\u306b(\u6050\u3089\u304f<a href=\"https:\/\/build.microsoft.com\/\" title=\"Microsoft Build 2017\" target=\"_blank\">Build 2017<\/a>\u306e\u30bf\u30a4\u30df\u30f3\u30b0\u306b\u5408\u308f\u305b\u3066)<a href=\"https:\/\/github.com\/microsoftgraph\/msgraph-sdk-php\" title=\"Get started with the Microsoft Graph SDK for PHP\" target=\"_blank\">Microsoft Graph\u30fbPHP\u7528SDK<\/a>\u306e\u5b89\u5b9a\u7248\u304c\u30ea\u30ea\u30fc\u30b9\u3055\u308c\u3066\u3044\u305f\u306e\u3067\u3001\u3055\u3063\u305d\u304f\u8a66\u3057\u3066\u307f\u307e\u3057\u305f\u3002<\/p>\n<h4 class=\"style4a\">\u30c6\u30b9\u30c8\u74b0\u5883<\/h4>\n<ul>\n<li>Windows 7 Professional SP1 64-bit<\/li>\n<li>XAMPP Portable Version: 5.6.30<\/li>\n<li>PHP Version 5.6.30<\/li>\n<li>Microsoft \u30a2\u30ab\u30a6\u30f3\u30c8<\/li>\n<\/ul>\n<h4 class=\"style4a\">\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3ID\u3068\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u30b7\u30fc\u30af\u30ec\u30c3\u30c8\u306e\u53d6\u5f97<\/h4>\n<p>API\u3092\u547c\u3073\u51fa\u3059\u306b\u3042\u305f\u308a\u3001\u307e\u305a\u306f\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3ID(\u30af\u30e9\u30a4\u30a2\u30f3\u30c8ID)\u3068\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u30b7\u30fc\u30af\u30ec\u30c3\u30c8(\u30af\u30e9\u30a4\u30a2\u30f3\u30c8\u30b7\u30fc\u30af\u30ec\u30c3\u30c8)\u306e\u6e96\u5099\u3092\u3057\u307e\u3059\u3002<\/p>\n<ol>\n<li>v2.0\u30a8\u30f3\u30c9\u30dd\u30a4\u30f3\u30c8\u3092\u4f7f\u7528\u3059\u308b\u305f\u3081\u3001<a href=\"https:\/\/apps.dev.microsoft.com\/\" title=\"Application Registration Portal\" target=\"_blank\">Application Registration Portal<\/a>\u306b\u30a2\u30af\u30bb\u30b9\u3057\u3001Microsoft \u30a2\u30ab\u30a6\u30f3\u30c8\u3067\u30b5\u30a4\u30f3\u30a4\u30f3\u3057\u307e\u3059\u3002<\/li>\n<li>\u300c<span style=\"color: #ff0000; font-weight: bold;\">\u30a2\u30d7\u30ea\u306e\u8ffd\u52a0<\/span>\u300d\u30dc\u30bf\u30f3\u3092\u30af\u30ea\u30c3\u30af\u3057\u307e\u3059\u3002<\/li>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.ka-net.org\/blog\/wp-content\/uploads\/MicrosoftGraph_PHPSDK_Sample_01.jpg\" alt=\"\" width=\"733\" height=\"202\" class=\"alignnone size-full wp-image-8470\" srcset=\"https:\/\/www.ka-net.org\/blog\/wp-content\/uploads\/MicrosoftGraph_PHPSDK_Sample_01.jpg 733w, https:\/\/www.ka-net.org\/blog\/wp-content\/uploads\/MicrosoftGraph_PHPSDK_Sample_01-300x83.jpg 300w\" sizes=\"auto, (max-width: 733px) 100vw, 733px\" \/><\/p>\n<li>Register your application\u753b\u9762\u304c\u8868\u793a\u3055\u308c\u305f\u3089\u3001\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u540d\u3084\u9023\u7d61\u5148\u3092\u5165\u529b\u3057\u3066\u3001\u300c<span style=\"color: #ff0000; font-weight: bold;\">Create<\/span>\u300d\u30dc\u30bf\u30f3\u3092\u30af\u30ea\u30c3\u30af\u3057\u307e\u3059\u3002<\/li>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.ka-net.org\/blog\/wp-content\/uploads\/MicrosoftGraph_PHPSDK_Sample_02.jpg\" alt=\"\" width=\"601\" height=\"623\" class=\"alignnone size-full wp-image-8471\" srcset=\"https:\/\/www.ka-net.org\/blog\/wp-content\/uploads\/MicrosoftGraph_PHPSDK_Sample_02.jpg 601w, https:\/\/www.ka-net.org\/blog\/wp-content\/uploads\/MicrosoftGraph_PHPSDK_Sample_02-289x300.jpg 289w\" sizes=\"auto, (max-width: 601px) 100vw, 601px\" \/><\/p>\n<li>\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u306e\u767b\u9332\u753b\u9762\u304c\u8868\u793a\u3055\u308c\u305f\u3089\u3001\u300c<span style=\"color: #ff0000; font-weight: bold;\">\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3 ID<\/span>\u300d(\u30af\u30e9\u30a4\u30a2\u30f3\u30c8ID)\u3092\u30b3\u30d4\u30fc\u3057\u3066\u304a\u304d\u307e\u3059\u3002<\/li>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.ka-net.org\/blog\/wp-content\/uploads\/MicrosoftGraph_PHPSDK_Sample_03.jpg\" alt=\"\" width=\"612\" height=\"357\" class=\"alignnone size-full wp-image-8472\" srcset=\"https:\/\/www.ka-net.org\/blog\/wp-content\/uploads\/MicrosoftGraph_PHPSDK_Sample_03.jpg 612w, https:\/\/www.ka-net.org\/blog\/wp-content\/uploads\/MicrosoftGraph_PHPSDK_Sample_03-300x175.jpg 300w\" sizes=\"auto, (max-width: 612px) 100vw, 612px\" \/><\/p>\n<li>\u300c<span style=\"color: #ff0000; font-weight: bold;\">\u65b0\u3057\u3044\u30d1\u30b9\u30ef\u30fc\u30c9\u3092\u751f\u6210<\/span>\u300d\u30dc\u30bf\u30f3\u3092\u30af\u30ea\u30c3\u30af\u3057\u3066\u3001\u751f\u6210\u3055\u308c\u305f\u30d1\u30b9\u30ef\u30fc\u30c9\u3092\u30b3\u30d4\u30fc\u3057\u3066\u304a\u304d\u307e\u3059\u3002\u3053\u306e\u30d1\u30b9\u30ef\u30fc\u30c9\u304c\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u30b7\u30fc\u30af\u30ec\u30c3\u30c8(\u30af\u30e9\u30a4\u30a2\u30f3\u30c8\u30b7\u30fc\u30af\u30ec\u30c3\u30c8)\u3068\u306a\u308a\u307e\u3059\u3002<\/li>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.ka-net.org\/blog\/wp-content\/uploads\/MicrosoftGraph_PHPSDK_Sample_04.jpg\" alt=\"\" width=\"479\" height=\"117\" class=\"alignnone size-full wp-image-8473\" srcset=\"https:\/\/www.ka-net.org\/blog\/wp-content\/uploads\/MicrosoftGraph_PHPSDK_Sample_04.jpg 479w, https:\/\/www.ka-net.org\/blog\/wp-content\/uploads\/MicrosoftGraph_PHPSDK_Sample_04-300x73.jpg 300w\" sizes=\"auto, (max-width: 479px) 100vw, 479px\" \/><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.ka-net.org\/blog\/wp-content\/uploads\/MicrosoftGraph_PHPSDK_Sample_05.jpg\" alt=\"\" width=\"496\" height=\"299\" class=\"alignnone size-full wp-image-8474\" srcset=\"https:\/\/www.ka-net.org\/blog\/wp-content\/uploads\/MicrosoftGraph_PHPSDK_Sample_05.jpg 496w, https:\/\/www.ka-net.org\/blog\/wp-content\/uploads\/MicrosoftGraph_PHPSDK_Sample_05-300x181.jpg 300w\" sizes=\"auto, (max-width: 496px) 100vw, 496px\" \/><\/p>\n<li>\u300c<span style=\"color: #ff0000; font-weight: bold;\">\u30d7\u30e9\u30c3\u30c8\u30d5\u30a9\u30fc\u30e0\u306e\u8ffd\u52a0<\/span>\u300d\u30dc\u30bf\u30f3\u3092\u30af\u30ea\u30c3\u30af\u3057\u3066\u3001\u300c<span style=\"color: #ff0000; font-weight: bold;\">Web<\/span>\u300d\u3092\u8ffd\u52a0\u3057\u307e\u3059\u3002<\/li>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.ka-net.org\/blog\/wp-content\/uploads\/MicrosoftGraph_PHPSDK_Sample_06.jpg\" alt=\"\" width=\"407\" height=\"113\" class=\"alignnone size-full wp-image-8475\" srcset=\"https:\/\/www.ka-net.org\/blog\/wp-content\/uploads\/MicrosoftGraph_PHPSDK_Sample_06.jpg 407w, https:\/\/www.ka-net.org\/blog\/wp-content\/uploads\/MicrosoftGraph_PHPSDK_Sample_06-300x83.jpg 300w\" sizes=\"auto, (max-width: 407px) 100vw, 407px\" \/><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.ka-net.org\/blog\/wp-content\/uploads\/MicrosoftGraph_PHPSDK_Sample_07.jpg\" alt=\"\" width=\"622\" height=\"439\" class=\"alignnone size-full wp-image-8476\" srcset=\"https:\/\/www.ka-net.org\/blog\/wp-content\/uploads\/MicrosoftGraph_PHPSDK_Sample_07.jpg 622w, https:\/\/www.ka-net.org\/blog\/wp-content\/uploads\/MicrosoftGraph_PHPSDK_Sample_07-300x212.jpg 300w\" sizes=\"auto, (max-width: 622px) 100vw, 622px\" \/><\/p>\n<li>\u300c<span style=\"color: #ff0000; font-weight: bold;\">\u30ea\u30c0\u30a4\u30ec\u30af\u30c8 URL<\/span>\u300d\u6b04\u306b\u8a8d\u8a3c\u5f8c\u306b\u98db\u3070\u3055\u308c\u308b\u5148\u306eURL(\u30ea\u30c0\u30a4\u30ec\u30af\u30c8URL)\u3092\u5165\u529b\u3057\u307e\u3059\u3002<\/li>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.ka-net.org\/blog\/wp-content\/uploads\/MicrosoftGraph_PHPSDK_Sample_08.jpg\" alt=\"\" width=\"754\" height=\"410\" class=\"alignnone size-full wp-image-8477\" srcset=\"https:\/\/www.ka-net.org\/blog\/wp-content\/uploads\/MicrosoftGraph_PHPSDK_Sample_08.jpg 754w, https:\/\/www.ka-net.org\/blog\/wp-content\/uploads\/MicrosoftGraph_PHPSDK_Sample_08-300x163.jpg 300w\" sizes=\"auto, (max-width: 754px) 100vw, 754px\" \/><\/p>\n<li>\u300c<span style=\"color: #ff0000; font-weight: bold;\">Microsoft Graph \u306e\u30a2\u30af\u30bb\u30b9\u8a31\u53ef<\/span>\u300d\u306f\u4e00\u5148\u305a\u300c<span style=\"color: #ff0000; font-weight: bold;\">User.Read<\/span>\u300d\u3060\u3051\u306b\u3057\u3066\u304a\u304d\u307e\u3059\u3002\u5fc5\u8981\u306b\u5fdc\u3058\u3066\u3001\u3053\u3053\u3067\u30b9\u30b3\u30fc\u30d7\u3092\u8ffd\u52a0\u3057\u307e\u3059\u3002<\/li>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.ka-net.org\/blog\/wp-content\/uploads\/MicrosoftGraph_PHPSDK_Sample_09.jpg\" alt=\"\" width=\"712\" height=\"193\" class=\"alignnone size-full wp-image-8478\" srcset=\"https:\/\/www.ka-net.org\/blog\/wp-content\/uploads\/MicrosoftGraph_PHPSDK_Sample_09.jpg 712w, https:\/\/www.ka-net.org\/blog\/wp-content\/uploads\/MicrosoftGraph_PHPSDK_Sample_09-300x81.jpg 300w\" sizes=\"auto, (max-width: 712px) 100vw, 712px\" \/><\/p>\n<li>\u4eca\u56de\u306f\u300c<span style=\"color: #ff0000; font-weight: bold;\">\u30d7\u30ed\u30d5\u30a1\u30a4\u30eb<\/span>\u300d\u306f\u7a7a\u6b04\u306b\u3057\u3066\u304a\u304d\u307e\u3059\u3002<\/li>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.ka-net.org\/blog\/wp-content\/uploads\/MicrosoftGraph_PHPSDK_Sample_10.jpg\" alt=\"\" width=\"755\" height=\"557\" class=\"alignnone size-full wp-image-8479\" srcset=\"https:\/\/www.ka-net.org\/blog\/wp-content\/uploads\/MicrosoftGraph_PHPSDK_Sample_10.jpg 755w, https:\/\/www.ka-net.org\/blog\/wp-content\/uploads\/MicrosoftGraph_PHPSDK_Sample_10-300x221.jpg 300w\" sizes=\"auto, (max-width: 755px) 100vw, 755px\" \/><\/p>\n<li>\u300c<span style=\"color: #ff0000; font-weight: bold;\">\u4fdd\u5b58<\/span>\u300d\u30dc\u30bf\u30f3\u3092\u30af\u30ea\u30c3\u30af\u3057\u3066\u3001\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u306e\u8a2d\u5b9a\u3092\u4fdd\u5b58\u3057\u307e\u3059\u3002<\/li>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.ka-net.org\/blog\/wp-content\/uploads\/MicrosoftGraph_PHPSDK_Sample_11.jpg\" alt=\"\" width=\"793\" height=\"373\" class=\"alignnone size-full wp-image-8480\" srcset=\"https:\/\/www.ka-net.org\/blog\/wp-content\/uploads\/MicrosoftGraph_PHPSDK_Sample_11.jpg 793w, https:\/\/www.ka-net.org\/blog\/wp-content\/uploads\/MicrosoftGraph_PHPSDK_Sample_11-300x141.jpg 300w, https:\/\/www.ka-net.org\/blog\/wp-content\/uploads\/MicrosoftGraph_PHPSDK_Sample_11-768x361.jpg 768w, https:\/\/www.ka-net.org\/blog\/wp-content\/uploads\/MicrosoftGraph_PHPSDK_Sample_11-790x373.jpg 790w\" sizes=\"auto, (max-width: 793px) 100vw, 793px\" \/>\n<\/ol>\n<p>\u4ee5\u4e0a\u3067\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3ID\u3068\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u30b7\u30fc\u30af\u30ec\u30c3\u30c8\u306e\u6e96\u5099\u306f\u5b8c\u4e86\u3067\u3059\u3002<\/p>\n<h4 class=\"style4a\">SDK\u3068OAuth\u8a8d\u8a3c\u7528\u30e9\u30a4\u30d6\u30e9\u30ea\u306e\u6e96\u5099<\/h4>\n<p>SDK\u3092\u4f7f\u3063\u3066API\u3092\u547c\u3073\u51fa\u3059\u308f\u3051\u3067\u3059\u304c\u3001<a href=\"https:\/\/github.com\/microsoftgraph\/msgraph-sdk-php\" title=\"Get started with the Microsoft Graph SDK for PHP\" target=\"_blank\">GitHub<\/a>\u3092\u898b\u308b\u3068\u4e0b\u8a18\u306e\u3088\u3046\u306a\u8a18\u8ff0\u304c\u3042\u308a\u307e\u3059\u3002<\/p>\n<blockquote><p>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.<\/p><\/blockquote>\n<p>OAuth 2.0\u306e\u8a8d\u8a3c\u90e8\u5206\u306b\u95a2\u3057\u3066\u306fSDK\u306b\u542b\u307e\u308c\u3066\u3044\u306a\u3044\u305f\u3081\u3001\u81ea\u529b\u3067\u5b9f\u88c5\u3059\u308b\u304b\u9069\u5f53\u306a\u30e9\u30a4\u30d6\u30e9\u30ea\u3092\u4f7f\u3046\u5fc5\u8981\u304c\u3042\u308b\u3088\u3046\u3067\u3059\u3002<\/p>\n<p>\u4eca\u56de\u306f\u300c<a href=\"https:\/\/docs.microsoft.com\/ja-jp\/azure\/active-directory\/develop\/active-directory-v2-libraries\" title=\"Azure Active Directory v2.0 \u8a8d\u8a3c\u30e9\u30a4\u30d6\u30e9\u30ea | Microsoft Docs\" target=\"_blank\">Azure Active Directory v2.0 \u8a8d\u8a3c\u30e9\u30a4\u30d6\u30e9\u30ea<\/a>\u300d\u3067\u3082\u7d39\u4ecb\u3055\u308c\u3066\u3044\u308b\u300c<a href=\"https:\/\/github.com\/thephpleague\/oauth2-client\" title=\"OAuth 2.0 Client\" target=\"_blank\">PHP League oauth2-client<\/a>\u300d\u3092\u4f7f\u3046\u3053\u3068\u306b\u3057\u307e\u3059\u3002<\/p>\n<p>\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u306f\u7c21\u5358\u3067\u3001\u300c<a href=\"https:\/\/getcomposer.org\/\" title=\"Composer\" target=\"_blank\">composer install<\/a>\u300d\u3059\u308b\u3060\u3051\u3067\u3059\u3002<br \/>\n(\u5fc5\u8981\u306b\u5fdc\u3058\u3066\u3001\u5c0e\u5165\u3059\u308b\u30d0\u30fc\u30b8\u30e7\u30f3\u3092\u5909\u66f4\u3057\u3066\u304f\u3060\u3055\u3044\u3002)<\/p>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">{\r\n    &quot;require&quot;: {\r\n        &quot;league\/oauth2-client&quot;: &quot;~2.0&quot;,\r\n        &quot;microsoft\/microsoft-graph&quot;: &quot;1.0.*&quot;\r\n    }\r\n}<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.ka-net.org\/blog\/wp-content\/uploads\/MicrosoftGraph_PHPSDK_Sample_12.jpg\" alt=\"\" width=\"677\" height=\"348\" class=\"alignnone size-full wp-image-8481\" srcset=\"https:\/\/www.ka-net.org\/blog\/wp-content\/uploads\/MicrosoftGraph_PHPSDK_Sample_12.jpg 677w, https:\/\/www.ka-net.org\/blog\/wp-content\/uploads\/MicrosoftGraph_PHPSDK_Sample_12-300x154.jpg 300w\" sizes=\"auto, (max-width: 677px) 100vw, 677px\" \/><\/p>\n<p>\u7279\u306b\u30a8\u30e9\u30fc\u304c\u767a\u751f\u3057\u306a\u3051\u308c\u3070\u3001\u3053\u308c\u3067SDK\u306e\u6e96\u5099\u306f\u5b8c\u4e86\u3067\u3059\u3002<\/p>\n<h4 class=\"style4a\">Microsoft Graph SDK for PHP\u306b\u3088\u308bAPI\u306e\u547c\u3073\u51fa\u3057<\/h4>\n<p>\u6e96\u5099\u304c\u6574\u3063\u305f\u306e\u3067\u3001\u6b21\u306f\u3044\u3088\u3044\u3088\u30b3\u30fc\u30c9\u3092\u66f8\u3044\u3066\u3044\u304d\u307e\u3059\u3002<\/p>\n<p><span style=\"color: #ff0000; font-weight: bold;\">\u203b \u30b3\u30fc\u30c9\u5185\u306e\u300cclientId\u300d\u3068\u300cclientSecret\u300d\u3001\u300credirectUri\u300d\u306f\u305d\u308c\u305e\u308c\u3001\u4e0a\u8a18\u624b\u9806\u3067\u53d6\u5f97\u3057\u305f\u3082\u306e\u306b\u7f6e\u304d\u63db\u3048\u3066\u304f\u3060\u3055\u3044\u3002<\/span><\/p>\n<pre class=\"brush: php; title: ; notranslate\" title=\"\">&lt;?php\r\n  require_once '.\/vendor\/autoload.php';\r\n  use Microsoft\\Graph\\Graph;\r\n  use Microsoft\\Graph\\Model;\r\n  $accessToken = NULL;\r\n  \r\n  $provider = new \\League\\OAuth2\\Client\\Provider\\GenericProvider(&#x5B;\r\n    'clientId'                =&gt; '(\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3 ID)',\r\n    'clientSecret'            =&gt; '(\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3 \u30b7\u30fc\u30af\u30ec\u30c3\u30c8)',\r\n    'redirectUri'             =&gt; '(\u30ea\u30c0\u30a4\u30ec\u30af\u30c8 URL)',\r\n    'urlAuthorize'            =&gt; 'https:\/\/login.microsoftonline.com\/common\/oauth2\/v2.0\/authorize',\r\n    'urlAccessToken'          =&gt; 'https:\/\/login.microsoftonline.com\/common\/oauth2\/v2.0\/token',\r\n    'urlResourceOwnerDetails' =&gt; '',\r\n    'scopes'                  =&gt; 'user.read'\r\n  ]);\r\n  \r\n  \/\/\u30a2\u30af\u30bb\u30b9\u30c8\u30fc\u30af\u30f3\u53d6\u5f97\r\n  if($_SERVER&#x5B;'REQUEST_METHOD'] === 'GET' &amp;&amp; !isset($_GET&#x5B;'code']) &amp;&amp; !isset($_GET&#x5B;'error'])){\r\n    $authorizationUrl = $provider-&gt;getAuthorizationUrl();\r\n    header('Location: ' . $authorizationUrl);\r\n    exit();\r\n  }elseif($_SERVER&#x5B;'REQUEST_METHOD'] === 'GET' &amp;&amp; isset($_GET&#x5B;'code'])){\r\n    try{\r\n      $accessTokenObj = $provider-&gt;getAccessToken('authorization_code', &#x5B;\r\n        'code' =&gt; $_GET&#x5B;'code']\r\n      ]);\r\n      $accessToken = $accessTokenObj-&gt;getToken();\r\n    }catch(League\\OAuth2\\Client\\Provider\\Exception\\IdentityProviderException $e){\r\n      printf('Error:', $e-&gt;getMessage());\r\n    }\r\n  }\r\n  \r\n  \/\/Graph API\u547c\u3073\u51fa\u3057\r\n  if($accessToken){\r\n    $graph = new Graph();\r\n    $graph-&gt;setAccessToken($accessToken);\r\n    \r\n    $user = $graph-&gt;createRequest('GET', '\/me')\r\n              -&gt;setReturnType(Model\\User::class)\r\n              -&gt;execute();\r\n    echo 'Hello, ' . $user-&gt;getDisplayName();\r\n  }<\/pre>\n<p>\u4e0a\u8a18\u30b3\u30fc\u30c9\u306e\u30da\u30fc\u30b8\u3092\u958b\u304f\u3068\u3001Microsoft \u30a2\u30ab\u30a6\u30f3\u30c8\u306e\u30b5\u30a4\u30f3\u30a4\u30f3\u30da\u30fc\u30b8\u306b\u98db\u3070\u3055\u308c\u308b\u306e\u3067\u3001\u30b5\u30a4\u30f3\u30a4\u30f3\u3092\u884c\u3044\u307e\u3059\u3002<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.ka-net.org\/blog\/wp-content\/uploads\/MicrosoftGraph_PHPSDK_Sample_13.jpg\" alt=\"\" width=\"852\" height=\"586\" class=\"alignnone size-full wp-image-8482\" srcset=\"https:\/\/www.ka-net.org\/blog\/wp-content\/uploads\/MicrosoftGraph_PHPSDK_Sample_13.jpg 852w, https:\/\/www.ka-net.org\/blog\/wp-content\/uploads\/MicrosoftGraph_PHPSDK_Sample_13-300x206.jpg 300w, https:\/\/www.ka-net.org\/blog\/wp-content\/uploads\/MicrosoftGraph_PHPSDK_Sample_13-768x528.jpg 768w\" sizes=\"auto, (max-width: 852px) 100vw, 852px\" \/><\/p>\n<p>\u30b3\u30f3\u30bb\u30f3\u30c8UI\u304c\u8868\u793a\u3055\u308c\u308b\u306e\u3067\u3001\u300c<span style=\"color: #ff0000; font-weight: bold;\">\u306f\u3044<\/span>\u300d\u30dc\u30bf\u30f3\u3092\u30af\u30ea\u30c3\u30af\u3057\u3066\u3001\u30a2\u30af\u30bb\u30b9\u3092\u8a31\u53ef\u3057\u307e\u3059\u3002<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.ka-net.org\/blog\/wp-content\/uploads\/MicrosoftGraph_PHPSDK_Sample_14.jpg\" alt=\"\" width=\"434\" height=\"442\" class=\"alignnone size-full wp-image-8483\" srcset=\"https:\/\/www.ka-net.org\/blog\/wp-content\/uploads\/MicrosoftGraph_PHPSDK_Sample_14.jpg 434w, https:\/\/www.ka-net.org\/blog\/wp-content\/uploads\/MicrosoftGraph_PHPSDK_Sample_14-295x300.jpg 295w\" sizes=\"auto, (max-width: 434px) 100vw, 434px\" \/><\/p>\n<p>API\u306e\u547c\u3073\u51fa\u3057\u304c\u7121\u4e8b\u306b\u884c\u308f\u308c\u308c\u3070\u3001\u30e6\u30fc\u30b6\u30fc\u540d\u304c\u8868\u793a\u3055\u308c\u307e\u3059\u3002<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.ka-net.org\/blog\/wp-content\/uploads\/MicrosoftGraph_PHPSDK_Sample_15.jpg\" alt=\"\" width=\"377\" height=\"204\" class=\"alignnone size-full wp-image-8484\" srcset=\"https:\/\/www.ka-net.org\/blog\/wp-content\/uploads\/MicrosoftGraph_PHPSDK_Sample_15.jpg 377w, https:\/\/www.ka-net.org\/blog\/wp-content\/uploads\/MicrosoftGraph_PHPSDK_Sample_15-300x162.jpg 300w\" sizes=\"auto, (max-width: 377px) 100vw, 377px\" \/><\/p>\n<div id=\"single_banner_area2\" class=\"clearfix one_banner\">\n<div class=\"single_banner single_banner_left\">\n<script async src=\"https:\/\/pagead2.googlesyndication.com\/pagead\/js\/adsbygoogle.js\"><\/script>\r\n<!-- \u8a18\u4e8b\u4e2d(\u30c7\u30a3\u30b9\u30d7\u30ec\u30a4\u5e83\u544a\u30e6\u30cb\u30c3\u30c8) -->\r\n<ins class=\"adsbygoogle\"\r\n     style=\"display:block\"\r\n     data-ad-client=\"ca-pub-7306936664602087\"\r\n     data-ad-slot=\"5429724765\"\r\n     data-ad-format=\"auto\"\r\n     data-full-width-responsive=\"true\"><\/ins>\r\n<script>\r\n     (adsbygoogle = window.adsbygoogle || []).push({});\r\n<\/script>\n<\/div>\n<div class=\"single_banner single_banner_right\">\n<a href=\"\" target=\"_blank\"><img decoding=\"async\" src=\"\" alt=\"\" title=\"\" \/><\/a>\n<\/div>\n<\/div>\n\n<h4 class=\"style4a\">\u304a\u308f\u308a\u306b<\/h4>\n<p>\u4eca\u56de\u521d\u3081\u3066Microsoft Graph\u306ePHP\u7528SDK\u3068OAuth\u8a8d\u8a3c\u7528\u30e9\u30a4\u30d6\u30e9\u30ea\u3092\u4f7f\u3063\u3066\u307f\u307e\u3057\u305f\u304c\u3001\u9a5a\u304f\u307b\u3069\u7c21\u5358\u306bAPI\u3092\u547c\u3073\u51fa\u305b\u307e\u3057\u305f\u3002<\/p>\n<p><a href=\"https:\/\/www.ka-net.org\/blog\/?p=6427\" title=\"Microsoft Graph\u3092VBA\u304b\u3089\u547c\u3073\u51fa\u3057\u3066OneNote\u306e\u30da\u30fc\u30b8\u5185\u5bb9\u3092\u53d6\u5f97\u3059\u308b | \u521d\u5fc3\u8005\u5099\u5fd8\u9332\" target=\"_blank\">VBA\u304b\u3089\u7121\u7406\u3084\u308a\u547c\u3093\u3060\u3068\u304d<\/a>\u3068\u306f\u96f2\u6ce5\u306e\u5dee\u3067\u3059\u3002<\/p>\n<p>\u3084\u306f\u308a\u5c02\u7528\u306b\u7528\u610f\u3055\u308c\u305fSDK\u306f\u4fbf\u5229\u3067\u3059\u306d\uff01<br \/>\n\u7ba1\u7406\u3082\u975e\u5e38\u306b\u697d\u306b\u306a\u308b\u3057\u3001Microsoft Graph\u3092\u4f7f\u3063\u305fWeb\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u3092\u958b\u767a\u3055\u308c\u308b\u65b9\u306f\u3001SDK\u306e\u5229\u7528\u3092\u5f37\u304f\u304a\u85a6\u3081\u3044\u305f\u3057\u307e\u3059\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"\u77e5\u3089\u306a\u3044\u9593\u306b(\u6050\u3089\u304fBuild 2017\u306e\u30bf\u30a4\u30df\u30f3\u30b0\u306b\u5408\u308f\u305b\u3066)Microsoft Graph\u30fbPHP\u7528SDK\u306e\u5b89\u5b9a\u7248\u304c\u30ea\u30ea\u30fc\u30b9\u3055\u308c\u3066\u3044\u305f\u306e\u3067\u3001\u3055\u3063\u305d\u304f\u8a66\u3057\u3066\u307f\u307e\u3057\u305f\u3002 \u30c6\u30b9\u30c8\u74b0\u5883 Windows 7 Professio [&hellip;]","protected":false},"author":1,"featured_media":8482,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"[Microsoft Graph SDK for PHP\u3092\u4f7f\u3063\u305fAPI\u306e\u547c\u3073\u51fa\u3057\u30b5\u30f3\u30d7\u30eb]","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[4,147,112],"tags":[],"class_list":["post-8469","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-office","category-microsoft-graph","category-office365"],"aioseo_notices":[],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"https:\/\/www.ka-net.org\/blog\/wp-content\/uploads\/MicrosoftGraph_PHPSDK_Sample_13.jpg","jetpack_shortlink":"https:\/\/wp.me\/p4UZZr-2cB","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/www.ka-net.org\/blog\/index.php?rest_route=\/wp\/v2\/posts\/8469","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.ka-net.org\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.ka-net.org\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.ka-net.org\/blog\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.ka-net.org\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=8469"}],"version-history":[{"count":2,"href":"https:\/\/www.ka-net.org\/blog\/index.php?rest_route=\/wp\/v2\/posts\/8469\/revisions"}],"predecessor-version":[{"id":8486,"href":"https:\/\/www.ka-net.org\/blog\/index.php?rest_route=\/wp\/v2\/posts\/8469\/revisions\/8486"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.ka-net.org\/blog\/index.php?rest_route=\/wp\/v2\/media\/8482"}],"wp:attachment":[{"href":"https:\/\/www.ka-net.org\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=8469"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.ka-net.org\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=8469"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.ka-net.org\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=8469"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}