brainstream / nylas-php
Nylas PHP SDK for api version 3
Requires
- php: ^8.1
- ext-json: *
- guzzlehttp/guzzle: ^7.7
- respect/validation: ^2.2
Requires (Dev)
- fakerphp/faker: ^1.23
- mockery/mockery: ^1.6
- nunomaduro/collision: ^6.4
- phpunit/phpunit: ^10.2
- roave/security-advisories: dev-latest
- symfony/var-dumper: ^7.1
This package is auto-updated.
Last update: 2024-10-30 10:09:38 UTC
README
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:
⚙️ Install
This library is available on https://packagist.org/packages/brainstream/nylas-php
You can install it by running
composer require brainstream/nylas-php
⚡️Usage
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.
🚀 Making Your First Request
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.
Administrative Api info.
Application api
Application api could be like:
try { $applications = $nylasClient->Administration->Application->list(); print_r($applications); } catch (GuzzleException) {}
Authentication api
Nylas support 2 types of user authentication
- Nylas hosted auth(OAuth 2.0)
- Custom auth
Grant api
Grants associate with an application. It could be like:
try { $grants = $nylasClient->Administration->Grants->list(); print_r($grants); } catch (GuzzleException) {}
Connectors api
Connectors(providers) of an application.
try { $connectors = $nylasClient->Administration->Connectors->list(); print_r($connectors); } catch (GuzzleException) {}
Connectors Credential api
try { $credentials = $nylasClient->Administration->ConnectorsCredentials->list( PROVIDER_STRING ); print_r($credentials); } catch (GuzzleException) {} //NOTE: Replace "PROVIDER_STRING" with real provider string
Email, Calender and Draft apis usage
Email api
try { $messages = $nylasClient->Messages->Message->list( GRANT_ID_STRING ); print_r($messages); } catch (GuzzleException) {} //NOTE: Replace "GRANT_ID_STRING" with real grant id
Calendar api
try { $calendars = $nylasClient->Calendars->Calendar->list( GRANT_ID_STRING ); print_r($calendars); } catch (GuzzleException) {} //NOTE: Replace "GRANT_ID_STRING" with real grant id
Drafts api
try { $drafts = $nylasClient->Drafts->Draft->list( GRANT_ID_STRING ); print_r($drafts); } catch (GuzzleException) {} //NOTE: Replace "GRANT_ID_STRING" with real grant id
Launching the tests
- 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
Acknowledgements
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.
📝License
This project is licensed under the MIT License. See the LICENSE file for details.
Contact us
If you need additional assistance, drop us an email at info@brainstream.tech.