Download the PHP package cruide/starline-openapi-php without Composer
On this page you can find all versions of the php package cruide/starline-openapi-php. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package starline-openapi-php
Starline OpenApi for PHP
Author: Alexander Tischenko
Русская версия
PHP client library for StarLine OpenAPI — telematics for StarLine security systems: vehicle state, remote commands, events and tracking.
- PHP >= 8.0, only
ext-curlandext-json— zero external dependencies; - full SLID authentication with token caching and automatic re-auth on 401;
- captcha and SMS confirmation support during login;
- automatic captcha solving (pure PHP GD or Tesseract OCR);
- StarLineID token authentication (skip SLID chain);
- typed models (
UserInfo,Device,DeviceState); - universal
request()for any endpoint from the docs; - swappable HTTP client (interface) — easily plug in Guzzle/PSR-18.
This library is not affiliated with NPO StarLine. You are responsible for API usage (see StarLine terms of service).
Installation
Or locally via repositories in composer.json:
Getting App ID and Secret Key
- Register at the developer portal: https://developer.starline.ru
- Create an application — obtain your App ID and Secret Key.
Authentication flow (SLID)
| Step | Request | Parameters | Result |
|---|---|---|---|
| 1 | GET id.starline.ru/apiV3/application/getCode |
appId, secret=md5(appSecret) |
app code |
| 2 | GET id.starline.ru/apiV3/application/getToken |
appId, secret=md5(appSecret+code) |
app token |
| 3 | POST id.starline.ru/apiV3/user/login |
Header: token: <app_token>, form: login, pass=sha1(password) |
user_token |
| 4 | POST developer.starline.ru/json/v2/auth.slid |
JSON: {"slid_token":"<user_token>"} |
cookie slnet + user_id |
All subsequent requests use the Cookie: slnet=<token> header.
The entire chain is executed automatically by the library and cached
in TokenStorageInterface.
Quick start
SLID authentication
StarLineID token
Manual captcha / SMS
Auto-captcha + Tesseract (optional, requires tesseract-ocr)
API methods
| Method | Description |
|---|---|
$api->authenticate(bool $force = false) |
Full SLID authentication |
$api->authenticateWithSlidToken(string $token) |
Auth via StarLineID token (skip SLID) |
$api->authenticateWithCaptcha(string $sid, string $code) |
Retry auth with captcha |
$api->authenticateWithSms(string $code) |
Retry auth with SMS code |
$api->authenticateWithCaptchaAuto(OcrInterface $ocr) |
Auto-captcha: download, OCR, retry |
$api->setOcr(OcrInterface $ocr) |
Enable automatic captcha solving |
$api->user()->id() |
Current user ID |
$api->user()->info() |
UserInfo (profile + devices) |
$api->devices()->list() |
List of Device objects |
$api->devices()->state($deviceId) |
DeviceState (/json/v3/device/{id}/data) |
$api->devices()->details($deviceId) |
Full device info (/json/v1/device/{id}/details) |
$api->devices()->position($deviceId) |
Last known position (/json/v1/device/{id}/position) |
$api->devices()->setParam($deviceId, $params) |
Send command (/json/v1/device/{id}/set_param) |
$api->devices()->arm/disarm/startEngine/stopEngine($deviceId) |
Common commands |
$api->devices()->events($deviceId, $periodStart, $periodEnd) |
Events in time range |
$api->devices()->eventType($id) |
Single event type description |
$api->devices()->eventTypes() |
All event types library |
$api->devices()->ways($deviceId, $begin, $end, $extra) |
GPS track (coordinates, mileage, travel time) |
$api->get($path, $query) / $api->post($path, $json) |
Generic requests |
Token storage
By default, tokens live only in process memory. For web apps / daemons,
implement TokenStorageInterface, e.g. with Laravel cache:
Error handling
| Exception | When |
|---|---|
StarlineAuthException |
invalid App ID/Secret/login/password, expired tokens (after one auto-retry) |
StarlineAuthCaptchaException |
captcha or SMS code required (if OCR is not configured or failed) |
StarlineApiException |
API errors (HTTP >= 400 or state/code != success); getRaw() — raw response |
StarlineHttpException |
cURL transport errors |
Notes
md5/sha1in the auth chain — StarLine protocol requirement.- If
user_idis not detected automatically, set it explicitly:$api->setUserId(123456); - For exact request body formats of commands and event/track parameters,
check the latest Swagger at https://developer.starline.ru —
use
$api->request()for non-standard requests.
Tests
License
MIT
All versions of starline-openapi-php with dependencies
ext-json Version *