承接 spryng/rest-api-php 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

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

spryng/rest-api-php

Composer 安装命令:

composer require spryng/rest-api-php

包简介

Implementation of the REST API in PHP

README 文档

README

This repository contains the source code for the Spryng SMS REST API library for PHP. This library will make it very easy to integrate the SMS gateway into your application. It offers all the functionality that the API has to offer.

Installation

Installation is easily done using composer:

composer require spryng/rest-api-php

When the installation is complete, you can initialize the library with your API key:

require_once "vendor/autoload.php";

use Spryng\SpryngRestApi\Spryng;

$spryng = new Spryng($apiKey);

Sending messages

To send a message, supply the send method with the information about the message you'd like to send:

use Spryng\SpryngRestApi\Objects\Message;
use Spryng\SpryngRestApi\Spryng;

$spryng = new Spryng($apiKey);

$message = new Message();
$message->setBody('My message');
$message->setRecipients(['31612344567', '31698765432']);
$message->setOriginator('My Company');

$response = $spryng->message->send($message);

if ($response->wasSuccessful())
{
	$message = $response->toObject();
	echo "Message with ID " . $message->getId() . " was send successfully!\n";
}
else if ($response->serverError())
{
	echo "Message could not be send because of a server error...\n";
}
else
{
	echo "Message could not be send. Response code: " . $response->getResponseCode() ."\n";
}

Getting info about a message

Single messages can be queried by their ID:

use Spryng\SpryngRestApi\Objects\Message;
use Spryng\SpryngRestApi\Spryng;

$spryng = new Spryng($apiKey);

$response = $spryng->message->getMessage("9dbc5ffb-7524-4fae-9514-51decd94a44f");

if ($resposne->wasSuccessful())
{
	echo "The body of the message is: " . $response->toObject()->getBody() . "\n";
}

Listing messages

You can list the messages you have send in a paginated manner. You can also apply filters to get a sub-set of the messages you have send:

use Spryng\SpryngRestApi\Objects\Message;
use Spryng\SpryngRestApi\Spryng;

$spryng = new Spryng($apiKey);

$response = $spryng->message->showAll(
	1, // page
	20, // limit: items per page
	[ // An array of filters
		'recipient_number' => '31612345667'
	]
);

if ($response->wasSuccessful())
{
	// Will return an instance of MessageCollection
	$messages = $response->toObject();
	echo "Found " . $messages->getTotal() . " results:\n";
	
	foreach ($messages->getData() as $message)
	{
		echo sprintf("ID: %s ('%s') send on: %s\n", 
			$message->getId(), 
			$message->getBody(), 
			$message->getCreatedAt()
		);
	}
}

Getting your balance

You can also check the remaining credit balance on your account:

use Spryng\SpryngRestApi\Objects\Message;
use Spryng\SpryngRestApi\Spryng;

$spryng = new Spryng($apiKey);

$balance = $spryng->balance->get()->toObject();
echo "You have " . $balance->getAmount() . " credits remaining\n";

spryng/rest-api-php 适用场景与选型建议

spryng/rest-api-php 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 308.49k 次下载、GitHub Stars 达 3, 最近一次更新时间为 2019 年 06 月 01 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「php」 「text」 「rest」 「api」 「sms」 「gateway」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

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

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

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

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

GitHub 信息

  • Stars: 3
  • Watchers: 3
  • Forks: 8
  • 开发语言: PHP

其他信息

  • 授权协议: BSD-2-Clause
  • 更新时间: 2019-06-01