masgeek/fuelrod-rest-api-client
Composer 安装命令:
composer require masgeek/fuelrod-rest-api-client
包简介
Fuelrod REST api package for messaging and other things
README 文档
README
PHP client library for the Fuelrod messaging API.
Requirements
- PHP 8.2 or higher
- ext-curl, ext-json, ext-mbstring
Installation
composer require masgeek/fuelrod-rest-api-client
Usage
Credential-based authentication
use Fuelrod\Fuelrod; $client = new Fuelrod( username: 'your-username', password: 'your-password', baseUrl: 'https://api.fuelrod.co.ke', );
API key authentication
Pass an API key as the fourth argument. When an API key is provided the user
and password fields are omitted from every request payload.
$client = new Fuelrod( username: 'your-username', password: 'your-password', baseUrl: 'https://api.fuelrod.co.ke', apiKey: 'your-api-key', );
Sending a single SMS
$response = $client->singleSms([ 'to' => '0712345678', // or E.164: '+254712345678' 'message' => 'Hello from Fuelrod!', ]); // $response['status'] === 'success' | 'error' // $response['data'] === decoded response body
Sending a plain SMS
$response = $client->plainSms([ 'to' => '+254712345678', 'message' => 'Hello from Fuelrod!', ]);
Sending a premium SMS
$response = $client->premiumSms([ 'to' => '+254712345678', 'message' => 'Hello from Fuelrod!', ]);
Response shape
Every method returns an associative array:
| Key | Type | Description |
|---|---|---|
status |
string |
"success" on 2xx, "error" on a 4xx client error |
data |
object|string |
Decoded JSON body, or raw string if the body is not JSON |
Server-level errors (5xx, network timeouts) throw GuzzleHttp\Exception\GuzzleException.
Validation errors
FuelrodException (code 422) is thrown when:
tois missing, empty, or not a stringmessageis missing or empty- The phone number does not match
+?[0-9]{7,15}(E.164 or local format)
Phone number format
| Format | Example |
|---|---|
| Local | 0712345678 |
| E.164 | +254712345678 |
Running tests
composer test
License
MIT
统计信息
- 总下载量: 430
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 17
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2023-01-12