定制 revolution/laravel-switchbot 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

revolution/laravel-switchbot

最新稳定版本:1.4.0

Composer 安装命令:

composer require revolution/laravel-switchbot

包简介

SwitchBot API for Laravel

README 文档

README

This package provides a simple integration with the SwitchBot API using Laravel's HTTP client macros.

For specific API details, please refer to the official SwitchBot API repository: https://github.com/OpenWonderLabs/SwitchBotAPI

Ask DeepWiki

Requirements

  • PHP >= 8.3
  • Laravel >= 12.0

Installation

composer require revolution/laravel-switchbot

Configuration

Get tokens from the SwitchBot app.

.env

SWITCHBOT_TOKEN=
SWITCHBOT_SECRET=

Usage

Built as a Laravel HTTP client macro.

use Illuminate\Support\Facades\Http;

$response = Http::switchbot()->get('devices');

dump($response->json());

$deviceId = $response->json('body.deviceList.0.deviceId');
if (filled($deviceId)) {
    $response = Http::switchbot()->get("devices/$deviceId/status");
    dump($response->json());
}
use Illuminate\Support\Facades\Http;

$response = Http::switchbot()->get('scenes');
dump($response->json());

Testing

use Illuminate\Support\Facades\Http;

Http::fake([
    '*' => Http::response([
        "statusCode" => 100,
        "body" => [
            "deviceList" => [],
            "infraredRemoteList" => [],
        ],
        "message" => "success",
   ]),
]);

$response = Http::switchbot()->get('devices');

$this->assertSame(100, $response->json('statusCode'));

LICENSE

MIT

统计信息

  • 总下载量: 7.57k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2022-10-09

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固