estandarte/ifttt-webhook

IFTTT webhook服务适配器

v1.0 2020-07-20 17:41 UTC

This package is auto-updated.

Last update: 2024-09-21 03:03:47 UTC


README

IFTTT webhook服务适配器。 (rumd3x/ifttt-webhook的分支)

此库符合Estandarte标准的通知服务。

安装

composer require estandarte/ifttt-webhook

用法

<?php
require 'vendor/autoload.php';

use Estandarte\IFTTT\Event;
use Estandarte\IFTTT\Trigger;

/**
 * Create event object passing the name
 * of the event, like "button_pressed" or "front_door_opened"
**/
$event = new Event('event_name');

/**
 * With an optional JSON body of:
 * { "value1" : "", "value2" : "", "value3" : "" }
 *
 * The data is completely optional, and you can also
 * This content will be passed on to the Action in your Recipe.
 *
 * Use Any of the syntaxes below
**/
$event->withValue1('value1')->withValue2('value2')->withValue3('value3');

$event = $event->withValue2('value2');
$event->withValue3('value3');
$event->withValue1('value1');

/**
 * Create the trigger object by passing your IFTTT Webhook Key
**/
$trigger = new Trigger('your-webhook-key');

/**
 * Now call the notify method passing the event object
 * to the trigger object and get the response.
**/
$response = $trigger->notify($event);

/**
 * You can optinally add a delay number in seconds
 * before the request is made
 *
 * Use any of the syntaxes below
**/
$response = $trigger->withDelay(10)->notify($event);

$trigger->withDelay(10);
$response = $trigger->notify($event);

$trigger = $trigger->withDelay(10);
$response = $trigger->notify($event);