purelines/whapi-sdk
最新稳定版本:v1.0.1
Composer 安装命令:
composer require purelines/whapi-sdk
包简介
Fixed version of PHP SDK for Whapi.Cloud API to interact with WhatsApp via HTTP.
关键字:
README 文档
README
Fixed version of PHP SDK for Whapi.Cloud API to interact with WhatsApp via HTTP.
- Official API docs: https://whapi.cloud/docs
What is this?
This SDK is auto-generated using OpenAPI Generator, based on Whapi.Cloud's official OpenAPI specification.
The spec was patched to make the PHP client work as expected.
Fixes applied
- Property name collision causing
Cannot redeclareerror: removed a send-onlyfilenameproperty from content models to avoid agetFilename()vsgetFileName()method conflict in the generated PHP client. - Boolean query parameter format: adjusted to use string values as required by the Whapi API, since OpenAPI Generator defaults to integers.
- OpenAPI 3.0 compatibility: cleaned up several validator warnings (e.g., no siblings next to
$ref, moved misplacedexamplefields).
Installation
composer require purelines/whapi-sdk
Quick start
<?php require __DIR__ . '/vendor/autoload.php'; use Purelines\WhapiSdk\Api\MessagesApi; use Purelines\WhapiSdk\ApiException; use Purelines\WhapiSdk\Configuration; use Purelines\WhapiSdk\Model\SenderText; $config = Configuration::getDefaultConfiguration() // Set your API token (copy it from Whapi panel, channel page): ->setAccessToken('YOUR_TOKEN') // Use string format for boolean query parameters (required by Whapi): ->setBooleanFormatForQueryString(Configuration::BOOLEAN_FORMAT_STRING); $api = new MessagesApi(new GuzzleHttp\Client(), $config); // Send a text message $sender = new SenderText(); $sender->setTo('13016789891'); // E.164 format, no spaces $sender->setBody('Hello from Whapi SDK!'); try { $result = $api->sendMessageText($sender); print_r($result); } catch (ApiException|InvalidArgumentException $e) { echo 'API error: ', $e->getMessage(); }
Tip: For receiving messages, set up a webhook in the Whapi panel for real-time delivery.
Regenerate SDK from spec
Update openapi.yaml and then:
# Install dependencies composer install # Generate PHP client using OpenAPI Generator docker run --rm \ -v "$(pwd):/local" \ openapitools/openapi-generator-cli generate \ -i /local/openapi.yaml \ -c /local/config.yaml \ -g php \ -o /local # Format generated PHP code with php-cs-fixer vendor/bin/php-cs-fixer fix
- The generated API docs are in ./docs/.
- For the authoritative API reference, see https://whapi.cloud/docs.
统计信息
- 总下载量: 21
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2025-10-29