Skip to content

Latest commit

 

History

History
executable file
·
71 lines (44 loc) · 2.66 KB

README.md

File metadata and controls

executable file
·
71 lines (44 loc) · 2.66 KB

HackApi

A fast, lighweight and solid API client written in PHP, to interact with various devices (mainly Routers, Modems or Smart Home hardware).

You can use it to interface with the currently implemented devices, or use it as a base to quickly develop your own client.

Why HackApi ?

While numerous API clients and frameworks excel with well-documented public APIs, they often prove excessive and challenging for tasks involving hardware devices like routers, modems, ISP boxes, and smart home devices. In situations where internal APIs, often undocumented and not intended for public access, come into play, existing tools can be overcomplicated, possess a steep learning curve, and lack suitability.

Enter HackApi: a straightforward, lightweight solution designed for ease of learning and debugging, specifically catering to the challenges posed by undocumented APIs. With just the HackApi main class file and a concise device-specific class file (e.g., openwrt) accompanied by its autogenerated trait.php file from a template.php file (essentially an API endpoint definition), HackApi simplifies the process, eliminating the need to reinvent the wheel.

Features

  • Standardised API methods
  • Full debug to ease API client development
  • Template based for building API endpoints methods & documentation very quickly
  • CLI commands to build, test, and debug API methods

Currently Supported Devices

All tested models are listed in: /src/devices/(BRAND)/Readme.md

Requirements

  • php >= 5.4
  • curl php extension

How to use

Example:

require('src/devices/huawei_modem/main.php');
$client= new HackApi_Huawei_modem();

//Set Credentials (if not set in default.php) file
//$client->SetHost('192.168.0.1');
//$client->SetLogin('admin','password');

// List messages from the SMS Inbox
$messages = $client->ApiSmsListReceived();
print_r($messages);

// Send an SMS
$done = $client->ApiSmsSend('0612345678','Hello world');

// Reboot modem
$done = $client->ApiReboot();

Very Simple, isn't it?

Contribute

  • Please submit the products models that you have tested
  • Write new device specifics clients and submit them back
  • Enhance the documentation : yes, I know, my english writing sucks!
  • Pull Requests are always welcome!

Enjoy!