stephangroen/tesla-php-client
Composer 安装命令:
composer require stephangroen/tesla-php-client
包简介
A PHP Client for the Tesla API
README 文档
README
A PHP client for easy integration of the Tesla API
This client is very basic, so most changes to the Tesla API will automatically be accomodated for. You can find the docs of the API at https://tesla-api.timdorr.com/
Installation
This project can easily be installed through Composer.
composer require stephangroen/tesla-php-client
One-time authentication process
Before you can start, you will first need to get an access token. This is a one-time process. Fortunatly the client makes this very simple. Get the client_id and client_secret here: http://pastebin.com/fX6ejAHd. You need to add them to you environment via a .env file in your existing project or use the functions supplied by the client. You need your email address and password you use for My Tesla. With these credentials you can get the access token.
$tesla = new StephanGroen\Tesla\Tesla(); $tesla->setClientId('client_id_here'); $tesla->setClientSecret('client_secret_here'); $accessToken = $tesla->getAccessToken('your_username', 'your_password');
The access token is the only authentication token you need after this one-time process.
Use the client
Next time you'd like to use the client, initiate it with the access token:
$tesla = new StephanGroen\Tesla\Tesla('your_access_token');
Get and set your vehicle id
In order to execute vehicle specific calls, you need your vehicle id. Retrieve this by requesting all vehicles for your account:
$tesla = new StephanGroen\Tesla\Tesla(); $tesla->vehicles();
This will return an array with information about your vehicles. Extract the id from the respone, not the vehicle_id which is used for Tesla internal purposes. You might want to store this id locally for future use. When you have the id, let the client know as follows:
$tesla = new StephanGroen\Tesla\Tesla(); $tesla->setVehicleId(123);
Example call
Calls are very simple, read the source code and API docs to find out all available calls. For example, set the charge limit to 90 percent:
$tesla = new StephanGroen\Tesla\Tesla('87dsfg76sdfg765sdfg765dsfg76fgds76'); $tesla->setVehicleId(123); $tesla->setChargeLimit(90);
So, for every use you initiate the client and set the vehicle id to execute calls for.
Client response
All calls just return an array with the data as described in the API docs mentioned above.
408 responses
You might get some 408 responses when your vehicle still needs to wake up. Wait for a moment and try again.
stephangroen/tesla-php-client 适用场景与选型建议
stephangroen/tesla-php-client 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 354 次下载、GitHub Stars 达 17, 最近一次更新时间为 2016 年 12 月 22 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「php」 「api」 「tesla」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 stephangroen/tesla-php-client 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 stephangroen/tesla-php-client 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 stephangroen/tesla-php-client 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
A PSR-7 compatible library for making CRUD API endpoints
Alfabank REST API integration
A simple Laravel package to help you connect to your Tesla(s).
Laravel Tesla Api Client Wrapper for https://packagist.org/packages/avido/tesla-api-client
Zero-dependency raw PHP DNS resolver, domain-ownership verification, and intoDNS/MxToolbox-style diagnostics. Queries authoritative nameservers directly over sockets — never trusts the recursive cache for ownership checks.
A lightweight plain-PHP framework for database-backed CRUD APIs.
统计信息
- 总下载量: 354
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 17
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2016-12-22