https://github.com/scaledrone/scaledrone-php
PHP API client for Scaledrone Realtime Messaging Service
https://github.com/scaledrone/scaledrone-php
php push-notifications real-time scaledrone
Last synced: about 1 year ago
JSON representation
PHP API client for Scaledrone Realtime Messaging Service
- Host: GitHub
- URL: https://github.com/scaledrone/scaledrone-php
- Owner: ScaleDrone
- Created: 2016-01-26T17:51:58.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2017-11-09T17:02:21.000Z (over 8 years ago)
- Last Synced: 2025-04-11T10:43:12.084Z (about 1 year ago)
- Topics: php, push-notifications, real-time, scaledrone
- Language: PHP
- Homepage: https://www.scaledrone.com/
- Size: 30.3 KB
- Stars: 11
- Watchers: 2
- Forks: 4
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# ScaleDrone PHP
Official ScaleDrone PHP pushing library. This is a wrapper around the REST API.
## Installation
Make sure you have [composer](https://getcomposer.org) installed.
Install it directly:
```
composer require scaledrone/scaledrone
```
Or add the following to your `composer.json`:
```json
{
"require": {
"scaledrone/scaledrone": "*"
}
}
```
Then update your dependencies:
```bash
$ php composer.phar update
```
## Usage
Create a new instance of ScaleDrone passing it the `channel_id` and `secret_key` that you can find from the channel's page
```php
$auth = array(
'channel_id' => 'CHANNEL_ID',
'secret_key' => 'SECRET_KEY'
);
$client = ScaleDrone\Client::create($auth);
```
If you wish to connect using a [JSON Web Token](https://www.scaledrone.com/docs/jwt-authentication) you can set it like this:
```php
$auth = array(
'channel_id' => 'CHANNEL_ID',
'bearer' => 'GENERATED_JWT'
);
$client = ScaleDrone\Client::create($auth);
```
Publishing a message
```php
$room = 'notifications';
$message = ['email' => 'test2@foo.bar', 'name' => 'php name'];
$response = $client->publish($room, $message);
```
Channel stats
```php
$response = $client->channel_stats();
```
Getting the complete list of users from all rooms
```php
$response = $client->members_list();
```
Getting the list of users in a room
```php
$response = $client->room_members_list('roomName');
```
Getting the list of rooms and their members
```php
$response = $client->all_room_members_list('roomName');
```
## Running Tests
Clone this repository and change directories to the repository root. Install all dependencies with `composer install`.
Then, just run `vendor/bin/phpunit`.