monscierge/php-sdk

This package is abandoned and no longer maintained. No replacement package was suggested.

Monscierge API bindings for PHP.

v0.1.1 2015-11-25 23:27 UTC

This package is not auto-updated.

Last update: 2020-01-24 16:02:07 UTC


README

A PHP wrapper for the Monscierge API. Create an application to get your client credentials in order to authenticate into the API.

Installation

Simply add the following to your composer.json require block:

'monscierge/php-sdk'

Examples

Authentication

All API methods require you be authenticated with a client that is registered with Monscierge. You will then use these credentials to instantiate your client instance.

$client = new \Monscierge\Client($client_id, $client_secret);

Client Authenticated Requests

You can exchange your client credentials for an OAuth token to use for any non-user authenticated APIs.

$oauth_token = $client->clientCredentialsExchange('uber4cats', 'nom0res3crets');

User Authenticated Requests

For methods that require user permission to alter context, you will need to either use OAuth flow and redirect the user to the authorization URL which will upon granting permission with the scopes requested allow access as the user.

$authorize_url = $client->authorizeUrl('http://example.app/monscierge/callback');

Alternatively, you can ask the user for their login credentials to be exchanged for an OAuth token, but this is generally not recommended.

$oauth_token = $client->basicCredentialsExchange('johnny.appleseed@monscierge.com', '123456');

Using OAuth tokens

Once you have an OAuth token, to then make API calls you should set the access token on the client instance.

$client->setAccessToken($oauth_token['access_token']);

You will also want to store the refresh_token in order to prevent sessions from timing out for your users of your application. When a token expires, you can exchange it for a new OAuth token to continue making API calls.

$client->refreshTokenExchange($oauth_token['refresh_token']);

Search places

$client->places('San Francisco');

Get list of requests for a user

$client->userRequests();

For more examples, dive into the SDK clients and look at the methods signatures. If you have any questions or feedback create an issue or send us an email.