quick-communication/php-sdk 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

quick-communication/php-sdk

Composer 安装命令:

composer require quick-communication/php-sdk

包简介

PHP SDK for Quick Communication CPaaS APIs.

README 文档

README

Lightweight PHP SDK for Quick Communication CPaaS APIs.

Install

composer require quick-communication/php-sdk

Quick Start

<?php

require __DIR__ . '/vendor/autoload.php';

use QuickCommunication\Client;

$client = new Client([
    'base_url' => 'https://ok-go.in',
    'app_key' => 'YOUR_APP_KEY',
    'app_secret' => 'YOUR_APP_SECRET',
]);

$response = $client->sms()->send([
    'dlt_template_id' => '1007452967110801758',
    'mobile_numbers' => '919999999999',
    'message' => 'This is your one time password {#var#}.',
    'route_type' => '0',
    'v1' => '123456',
]);

print_r($response);

Authentication

$client = new Client([
    'base_url' => 'https://ok-go.in',
    'app_key' => 'YOUR_APP_KEY',
    'app_secret' => 'YOUR_APP_SECRET',
]);

Supported Helpers

$client->sms()->send($payload);
$client->sms()->generateOtp($payload);
$client->sms()->campaignList($filters);
$client->sms()->templates();
$client->sms()->approvedSenderIds();

$client->whatsapp()->send($payload);
$client->whatsapp()->report($responseToken);
$client->whatsapp()->templates($templateName);

$client->email()->send($payload);
$client->email()->senderIdentities();
$client->email()->templates($templateName);
$client->email()->campaignList($filters);
$client->email()->report($responseToken);

$client->voice()->send($payload);
$client->voice()->sendOtp($payload);
$client->voice()->templates();

$client->account()->status();
$client->account()->balance();
$client->webhooks()->parse($payload);

Email Payload Example

$response = $client->email()->send([
    'sender_id' => 2000000001,
    'template_slug' => 'welcome-offer',
    'recipient_email' => 'customer@example.com',
    'recipient_name' => 'Customer Name',
    'attachment_paths' => [
        'uploads/email-attachments/offer-terms.pdf',
        'https://ok-go.in/uploads/email-attachments/catalog.pdf',
    ],
    'variables' => [
        'name' => 'Customer Name',
        'coupon_code' => 'WELCOME10',
    ],
]);

WhatsApp Payload Examples

Normal template without variables:

$response = $client->whatsapp()->send([
    'message' => [
        'content' => [
            'type' => 'TEMPLATE',
            'template' => [
                'templateId' => 'hello_world',
            ],
        ],
        'recipient' => [
            'to' => '919999999999',
            'recipient_type' => 'individual',
        ],
        'sender' => [
            'from' => '15550622381',
        ],
    ],
]);

Template with body variables:

$response = $client->whatsapp()->send([
    'message' => [
        'content' => [
            'type' => 'TEMPLATE',
            'language' => 'en',
            'template' => [
                'templateId' => 'promotion_text_only',
                'bodyParameterValues' => [
                    '0' => 'Amit',
                    '1' => 'WELCOME10',
                ],
            ],
        ],
        'recipient' => ['to' => '919999999999', 'recipient_type' => 'individual'],
        'sender' => ['from' => '15550622381'],
    ],
]);

Template with named variables:

$response = $client->whatsapp()->send([
    'message' => [
        'content' => [
            'type' => 'template',
            'language' => 'en',
            'template' => [
                'templateId' => 'order_update',
                'bodyParameterValues' => [
                    ['type' => 'text', 'parameter_name' => 'customer_name', 'text' => 'Amit'],
                    ['type' => 'text', 'parameter_name' => 'order_id', 'text' => 'ORD12345'],
                ],
            ],
        ],
        'recipient' => ['to' => '919999999999', 'recipient_type' => 'individual'],
        'sender' => ['from' => '15550622381'],
    ],
]);

Template with quick reply buttons:

$response = $client->whatsapp()->send([
    'message' => [
        'content' => [
            'type' => 'TEMPLATE',
            'template' => [
                'templateId' => 'confirm_interest',
                'buttons' => [
                    'quickReplies' => [
                        ['type' => 'QUICK_REPLY', 'index' => '0', 'payload' => 'Yes'],
                        ['type' => 'QUICK_REPLY', 'index' => '1', 'payload' => 'No'],
                    ],
                ],
            ],
        ],
        'recipient' => ['to' => '919999999999', 'recipient_type' => 'individual'],
        'sender' => ['from' => '15550622381'],
    ],
]);

Media template by URL:

$response = $client->whatsapp()->send([
    'message' => [
        'content' => [
            'type' => 'MEDIA_TEMPLATE',
            'template' => [
                'templateId' => 'image_offer',
                'media' => [
                    'type' => 'image',
                    'url' => 'https://ok-go.in/whatsapp-file/sample.jpg',
                ],
                'bodyParameterValues' => [
                    '0' => 'Amit',
                ],
            ],
        ],
        'recipient' => ['to' => '919999999999', 'recipient_type' => 'individual'],
        'sender' => ['from' => '15550622381'],
    ],
]);

Support

For credentials, sender ID approval, template setup, or delivery troubleshooting, contact the Quick Communication support team.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-06-27