ippanel/php-rest-sdk 问题修复 & 功能扩展

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

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

ippanel/php-rest-sdk

Composer 安装命令:

composer require ippanel/php-rest-sdk

包简介

IPPanel REST API client

README 文档

README

Build Status

Installation

use with composer:

composer require ippanel/php-rest-sdk

if you don't want to use composer, you can download it directly :

wget https://github.com/ippanel/php-rest-sdk/archive/master.zip

Examples

For using sdk, you have to create a client instance that gives you available methods on API

require 'autoload.php';

// you api key that generated from panel
$apiKey = "api-key";

$client = new \IPPanel\Client($apiKey);

...

Credit check

# return float64 type credit amount
$credit = $client->getCredit();

Send one to many

For sending sms, obviously you need originator number, recipients and message.

$messageId = $client->send(
    "+9810001",          // originator
    ["98912xxxxxxx"],    // recipients
    "ippanel is awesome",// message
    "description"        // is logged
);

If send is successful, a unique tracking code returned and you can track your message status with that.

Get message summery

$messageId = "message-tracking-code";

$message = $client->get_message($messageId);

echo $message->state;   // get message status
echo $message->cost;     // get message cost
echo $message->returnCost;  // get message payback

Get message delivery statuses

$messageId = "message-tracking-code"

list($statuses, $paginationInfo) = $client->fetchStatuses($messageId, 0, 10)

// you can loop in messages statuses list
foreach($statuses as status) {
    echo sprintf("Recipient: %s, Status: %s", $status->recipient, $status->status);
}

echo sprintf("Total: ", $paginationInfo->total);

Inbox fetch

fetch inbox messages

list($messages, $paginationInfo) = $client->fetchInbox(0, 10);

foreach($messages as $message) {
    echo sprintf("Received message %s from number %s in line %s", $message->message, $message->from, $message->to);
}

Pattern create

For sending messages with predefined pattern(e.g. verification codes, ...), you hav to create a pattern. a pattern at least have a parameter.

$patternVariables = [
    "name" => "string",
    "code" => "integer",
];

$code = $client->createPattern("%name% is awesome, your code is %code%", "description", 
    $patternVariables, '%', False);

echo $code;

Send with pattern

$patternValues = [
    "name" => "IPPANEL",
];

$messageId = $client->sendPattern(
    "t2cfmnyo0c",    // pattern code
    "+9810001",      // originator
    "98912xxxxxxx",  // recipient
    $patternValues,  // pattern values
);

Error checking

use IPPanel\Errors\Error;
use IPPanel\Errors\HttpException;

try{
    $messageId = $client->send("9810001", ["98912xxxxx"], "ippanel is awesome");
} catch (Error $e) { // ippanel error
    var_dump($e->unwrap()); // get real content of error
    echo $e->getCode();

    // error codes checking
    if ($e->code() == ResponseCodes::ErrUnprocessableEntity) {
        echo "Unprocessable entity";
    }
} catch (HttpException $e) { // http error
    var_dump($e->getMessage()); // get stringified error
    echo $e->getCode();
}

ippanel/php-rest-sdk 适用场景与选型建议

ippanel/php-rest-sdk 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 42.19k 次下载、GitHub Stars 达 28, 最近一次更新时间为 2020 年 02 月 18 日, 在 PHP 生态内属于活跃度较高的组件。

我们在过去多个企业项目中使用过 ippanel/php-rest-sdk 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 ippanel/php-rest-sdk 我们能提供哪些服务?
定制开发 / 二次开发

基于 ippanel/php-rest-sdk 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 42.19k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 28
  • 点击次数: 15
  • 依赖项目数: 9
  • 推荐数: 0

GitHub 信息

  • Stars: 28
  • Watchers: 6
  • Forks: 15
  • 开发语言: PHP

其他信息

  • 授权协议: BSD-2-Clause
  • 更新时间: 2020-02-18