messageapi/messageapi-php

使用一个API发送和接收来自任何聊天应用的短信

dev-master 2017-09-17 13:34 UTC

This package is not auto-updated.

Last update: 2024-09-18 03:14:21 UTC


README

文档

授权时,请使用此代码

require_once ('messageapi.php');
$messageapi=new \messageapi\messageapi('<YOUR_APP_SECRET>');

快速示例

创建集成

$result=$messageapi->integrations->Create('{
    "type":"line",
    "bot_id":"<BOT_ID>",
    "access_token":"<ACCESS_TOKEN>"
}');

创建客户

$result=$messageapi->customers->Create('{
    "email":"email@domain.com",
    "line":{"user_id":"225451339750443406022273244"}
}')

发送消息

$result=$messageapi->messaging->SendMessage('{
    "_customer_id":"customer_id",
    "messengerType":"line",
    "message":{
        "type":"text",
        "content":"your text"
    }
}')

添加Webhook

$result=$messageapi->webhooks->Create('{
    "event":"received_message",
    "webhook_url":"http://yourpath.com/path"
}')

更多示例

集成

获取
$messageapi->integrations->Get('<ID_INTEGRATION>');
$messageapi->integrations->GetAll();
创建
$messageapi->integrations->Create('{
    "type":"line",
    "bot_id":"<BOT_ID>",
    "access_token":"<ACCESS_TOKEN>"}');
更新
$messageapi->integrations->Update('<ID_INTEGRATION>','{
    "type":"line",
    "bot_id":"<BOT_ID>",
    "access_token":"<ACCESS_TOKEN>"}');
删除
 $messageapi->integrations->Remove('<ID_INTEGRATION>');

客户

获取
$messageapi->customers->Get('<ID_CUSTOMER>');
$messageapi->customers->GetAll();
创建
$messageapi->customers->Create('{
    "email":"email@domain.com",
    "line":{"user_id":"<USER_ID_OF_LINE>"}}');
更新
$messageapi->customers->Create('<ID_CUSTOMER>','{
    "email":"email@domain.com",
    "line":{"user_id":"<USER_ID_OF_LINE>"}}');
删除
$messageapi->customers->Remove('<ID_CUSTOMER>');