This is the GitHub repository for the Nylas PHP SDK.
The Nylas Communications Platform provides REST APIs for Email, Calendar, and Contacts, and the Nylas SDK is the quickest way to build your integration using PHP.
Here are some resources to help you get started:
This library is available on https://packagist.org/packages/brainstream/nylas-php
You can install it by running
composer require brainstream/nylas-php
To use this SDK, you must first get a free Nylas account.
Then, follow the Quickstart guide to set up your first app and get your API keys.
You use the NylasClient
object to make requests to the Nylas API. The SDK is organized into different resources, each of which has methods to make requests to the API. Each resource is available through the NylasClient
object configured with your API key.
For example, first configure client object like below:
use Nylas\Client;
require __DIR__ . '/vendor/autoload.php';
$options = [
'api_key' => 'NYLAS_API_KEY',
'client_id' => 'NYLAS_CLIENT_ID',
'region' => 'NYLAS_REGION', // optional - Default "us"
];
$nylasClient = new Client($options);
Then use it for make consecutive api requests.
Application api could be like:
try {
$applications = $nylasClient->Administration->Application->list();
print_r($applications);
} catch (GuzzleException) {}
Nylas support 2 types of user authentication
- Nylas hosted auth(OAuth 2.0)
- Custom auth
Grants associate with an application. It could be like:
try {
$grants = $nylasClient->Administration->Grants->list();
print_r($grants);
} catch (GuzzleException) {}
Connectors(providers) of an application.
try {
$connectors = $nylasClient->Administration->Connectors->list();
print_r($connectors);
} catch (GuzzleException) {}
try {
$credentials = $nylasClient->Administration->ConnectorsCredentials->list(
PROVIDER_STRING
);
print_r($credentials);
} catch (GuzzleException) {}
//NOTE: Replace "PROVIDER_STRING" with real provider string
try {
$messages = $nylasClient->Messages->Message->list(
GRANT_ID_STRING
);
print_r($messages);
} catch (GuzzleException) {}
//NOTE: Replace "GRANT_ID_STRING" with real grant id
try {
$calendars = $nylasClient->Calendars->Calendar->list(
GRANT_ID_STRING
);
print_r($calendars);
} catch (GuzzleException) {}
//NOTE: Replace "GRANT_ID_STRING" with real grant id
try {
$drafts = $nylasClient->Drafts->Draft->list(
GRANT_ID_STRING
);
print_r($drafts);
} catch (GuzzleException) {}
//NOTE: Replace "GRANT_ID_STRING" with real grant id
- Initialise composer dependency by
composer install
- Add your Nylas App. info in tests/AbsCase.php
- Launch the test with
composer run-script test
- Another way to run tests: ./tests/do.sh foo.php --filter fooMethod, see tests/do.sh
This project is based on lanlin/nylas-php, which is licensed under the MIT License. The original code has been modified and is also available under the MIT License.
This project is licensed under the MIT License. See the LICENSE file for details.
If you need additional assistance, drop us an email at info@brainstream.tech.