Black Friday sale is now on! 50% off Laravel: The Modular Way. Learn more

Laravel package MsGraph

David Carr

Microsoft Graph API Packages Laravel Framework PHP & MySQL

    I've released a new Laravel package called MsGraph that's essentially a wrapper for working with Microsoft Graph API.

    https://github.com/daveismynamelaravel/MsGraph

    The package comes with a few trait classes to offer simpler functions to working with Mail, Contacts and ToDo's more will be coming over the new few months. MsGraph can also be used to call an API endpoint directly.

    For instance to get a users emails:

    MsGraph::get('me/messages');

    or using a trait method:

    Msgraph::getEmails();

    When working with the endpoint you use MsGraph:: followed by the HTTP verb (get, post, put, patch or delete) then the endpoint URL and where needed an array of data.

    For instance to create a contact:

    $data = [
    	'displayName' => request('name'),
    	'givenName' => request('name'),
    	'emailAddresses' => [[
    		'address' => request('email'),
    		'name' => request('name')
    	]]
    ];
    
    MsGraph::post("me/contacts", $data);
    
    //OR use the trait
    MsGraph::createContact($data);

    This makes working with the Graph API simpler, I'll be writing tutorials on different use cases soon. In the meantime give it a whirl. https://github.com/daveismynamelaravel/MsGraph

    Laravel Modules Book by David Carr

    Help support the blog so that I can continue creating new content!

    Subscribe to my newsletter

    Subscribe and get my books and product announcements.

    © 2009 - 2022 DC Blog. All code MIT license. All rights reserved.