定制 purelines/whapi-sdk 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

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.

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 redeclare error: removed a send-only filename property from content models to avoid a getFilename() vs getFileName() 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 misplaced example fields).

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

统计信息

  • 总下载量: 21
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 2
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-10-29