ryodevz / mibot-api
MIBot API 封装库,方便使用。
v1.2.4
2022-06-15 15:21 UTC
Requires
- ryodevz/httpwrapper: dev-main
README
MIBot API 封装库,方便使用。
安装
composer require ryodevz/mibot-api
配置
<?php use Ryodevz\MiBot\Config; // API Token Config::setApiToken('6|Rjr8x0nuGRm9BwZLm5AwywmNP8O5N9rZZ7uyWw5J'); // Device ID Config::setDevice('6287743985629');
发送文本消息
<?php use Ryodevz\MiBot\Api; $receiver = '6287999999999'; $message_text = 'Hello World' $response = Api::textMessage($receiver, $message_text)->send(); var_dump($response);
发送按钮消息
<?php use Ryodevz\MiBot\Api; $receiver = '6287999999999'; $message_text = 'Hello World' $buttons = [ [ 'type' => 'reply', 'text' => 'Information', 'command' => 'info', ], [ 'type' => 'url', 'text' => 'Website', 'url' => 'https://profile.ytryo.my.id', ], [ 'type' => 'phone', 'text' => 'Contact Me', 'phone' => '6281917999999', ], ] $response = Api::buttonMessage($receiver, $message_text, $buttons)->send(); var_dump($response);
发送选项消息
<?php use Ryodevz\MiBot\Api; $receiver = '6287999999999'; $message_text = 'Hello World'; $button_text = 'Button Text'; $message_title = 'Naruto Shippuded'; $sections = [ [ 'title' => 'Section 1 title', 'rows' => [ [ 'title' => 'Episode 1', 'command' => 'eps_1', ], [ 'title' => 'Episode 2', 'command' => 'eps_2', ], [ 'title' => 'Episode 3', 'command' => 'eps_3', ], ] ], [ 'title' => 'Section 2 title', 'rows' => [ [ 'title' => 'Episode 4', 'command' => 'eps_4', ], ] ], ]; $response = Api::optionMessage($receiver, $message_text, $sections, $button_text, $message_title)->send(); var_dump($response);