Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
In this article, you add your own Microsoft Graph capabilities to the application you created in Build PHP apps with Microsoft Graph and app-only authentication. For example, you might want to add a code snippet from Microsoft Graph documentation or Graph Explorer, or code that you created.
Update the app
Add the following code to the
GraphHelper
class.public static function makeGraphCall(): void { // INSERT YOUR CODE HERE }
Replace the empty
makeGraphCall
function in main.php with the following.function makeGraphCall(): void { try { GraphHelper::makeGraphCall(); } catch (Exception $e) { print(PHP_EOL.'Error making Graph call'.PHP_EOL.PHP_EOL); } }
Choose an API
Find an API in Microsoft Graph you'd like to try. For example, the Create event API. You can use one of the examples in the API documentation, or create your own API request.
Configure permissions
Check the Permissions section of the reference documentation for your chosen API to see which authentication methods are supported. Some APIs don't support app-only, or personal Microsoft accounts, for example.
- To call an API with user authentication (if the API supports user (delegated) authentication), see the user (delegated) authentication tutorial.
- To call an API with app-only authentication (if the API supports it), add the required permission scope in the Microsoft Entra admin center.
Add your code
Add your code into the makeGraphCall
function in GraphHelper.php.
Related content
Now that you have a working app that calls Microsoft Graph, you can experiment and add new features.
- Learn how to use user (delegated) authentication with the Microsoft Graph PHP SDK.
- Visit the Overview of Microsoft Graph to see all of the data you can access with Microsoft Graph.