项目作者: ScaleDrone

项目描述 :
PHP API client for Scaledrone Realtime Messaging Service
高级语言: PHP
项目地址: git://github.com/ScaleDrone/scaledrone-php.git
创建时间: 2016-01-26T17:51:58Z
项目社区:https://github.com/ScaleDrone/scaledrone-php

开源协议:

下载


ScaleDrone PHP

Official ScaleDrone PHP pushing library. This is a wrapper around the REST API.

Installation

Make sure you have composer installed.

Install it directly:

  1. composer require scaledrone/scaledrone

Or add the following to your composer.json:

  1. {
  2. "require": {
  3. "scaledrone/scaledrone": "*"
  4. }
  5. }

Then update your dependencies:

  1. $ 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

  1. $auth = array(
  2. 'channel_id' => 'CHANNEL_ID',
  3. 'secret_key' => 'SECRET_KEY'
  4. );
  5. $client = ScaleDrone\Client::create($auth);

If you wish to connect using a JSON Web Token you can set it like this:

  1. $auth = array(
  2. 'channel_id' => 'CHANNEL_ID',
  3. 'bearer' => 'GENERATED_JWT'
  4. );
  5. $client = ScaleDrone\Client::create($auth);

Publishing a message

  1. $room = 'notifications';
  2. $message = ['email' => 'test2@foo.bar', 'name' => 'php name'];
  3. $response = $client->publish($room, $message);

Channel stats

  1. $response = $client->channel_stats();

Getting the complete list of users from all rooms

  1. $response = $client->members_list();

Getting the list of users in a room

  1. $response = $client->room_members_list('roomName');

Getting the list of rooms and their members

  1. $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.