Skip to content
Chatwork API PHP client library
PHP Makefile
Branch: master
Clone or download
xuanquynh and thphuong Add withApiToken and withAccessToken methods (#15)
* Add fromApiToken and fromAccessToken methods

* Correct tests

* Rename methods
Latest commit c020398 Aug 21, 2019
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
src Add withApiToken and withAccessToken methods (#15) Aug 20, 2019
tests Add withApiToken and withAccessToken methods (#15) Aug 20, 2019
.gitignore chore: add coverage make target Aug 1, 2019
.travis.yml
LICENSE chore: write something for README.md Jul 22, 2019
Makefile chore: add coverage make target Aug 1, 2019
README.md Add withApiToken and withAccessToken methods (#15) Aug 20, 2019
composer.json feat: add travis-ci Jul 22, 2019
phpunit.xml feat: add travis-ci Jul 22, 2019

README.md

Chatwork PHP API client library

Build Status Latest Stable Version Codecov GitHub

Requirements

  • PHP >= 7.0
  • PHP cURL

Installation

Using composer:

composer require sun-asterisk/chatwork-php

Usage

You may register an API Token here.

Create a chatwork client with an api token or an access token:


use SunAsterisk\Chatwork\Chatwork;

$chatwork = Chatwork::withAPIToken('your-api-token');

// $chatwork = Chatwork::withAccessToken('your-access-token');

Use chatwork client methods as these examples below:


// Get your personal information.
$me = $chatwork->me();

// Get your personal tasks.
$tasks = $chatwork->my()->tasks();

// Get members in a room.
$members = $chatwork->room($roomId)->members();

API methods are organized similar to the official API doc e.g.

Message builder

There's a helper for easily creating message.

use SunAsterisk\Chatwork\Helpers\Message;

$message = new Message('Hi there')
    ->info('Cloudy', 'Weather today');

$chatwork->room($roomId)->messages()->create((string) $message);

You can also access it via a static method of the Chatwork class.

$message = Chatwork::message('Hi there');

Verify webhook payload

There's also a helper for verifying the webhook payload signature.

use SunAsterisk\Chatwork\Helpers\Webhook;

$isValid = Webhook::verifySignature($yourWebhookToken, $requestBody, $signature);
You can’t perform that action at this time.