notifius/php-wctp
Composer 安装命令:
composer require notifius/php-wctp
包简介
A PHP library for creating and handling XML request/response objects for the WCTP v1.3r1 specification.
README 文档
README
A PHP library for creating and submitting XML WCTP requests and responses.
Getting Started
Add the library to your project using composer:
composer require notifius/php-wctp
Example usage:
use NotifiUs\WCTP\XML\ClientQuery; $clientQuery = new ClientQuery(); $xml = $clientQuery ->senderID( 'senderID' ) ->recipientID( 'recipientID' ) ->trackingNumber( 'trackingNumber' ) ->xml();
XML Request Method Templating
| WCTP Method | notifius/wctp | Status |
|---|---|---|
| wctp-ClientQuery | NotifiUs\WCTP\XML\ClientQuery | ✓ |
| wctp-LookupSubscriber | NotifiUs\WCTP\XML\LookupSubscriber | ✓ |
| wctp-DeviceLocation | NotifiUs\WCTP\XML\DeviceLocation | ✓ |
| wctp-MessageReply | NotifiUs\WCTP\XML\MessageReply | ✓ |
| wctp-PollForMessages | NotifiUs\WCTP\XML\PollForMessages | × |
| wctp-ReturnToSvc | NotifiUs\WCTP\XML\ReturnToSvc | ✓ |
| wctp-SendMsgMulti | NotifiUs\WCTP\XML\SendMsgMulti | × |
| wctp-StatusInfo | NotifiUs\WCTP\XML\StatusInfo | × |
| wctp-SubmitClientMessage | NotifiUs\WCTP\XML\SubmitClientMessage | ✓ |
| wctp-SubmitRequest | NotifiUs\WCTP\XML\SubmitRequest | ✓ |
| wctp-VersionQuery | NotifiUs\WCTP\XML\VersionQuery | ✓ |
Return Type
The $xml variable will be a SimpleXMLElement Object. You can get the XML as a string by calling $xml->asXML()
Relaxed parameter requirements
While we follow the WCTP recommendations for parameters and lengths, we don't enforce allowed characters. Anything that is not XML compliant will be automatically escaped, so keep that in mind. This should provide an additional level of flexibility (through conventions) and modernize the now ~15 year-old protocol.
Add WCTP token to wctp-Operation
For all XML WCTP methods below, you can optionally pass in a wctpToken to the constructor:
$clientQuery = new ClientQuery( 'token' );
This will add the XML attribute wctpToken="token" to the <wctp-Operation> element.
WCTP XML Methods
wctp-MessageReply
Create an XML representation of the wctp-MessageReply operation.
use Carbon\Carbon; use NotifiUs\WCTP\XML\MessageReply; $messageReply = new MessageReply(); $xml = $messageReply ->messageID( 321 ) ->senderID( 'senderID' ) ->recipientID( 'recipientID' ) ->responseToMessageID( 123 ) ->submitTimestamp( Carbon::now() ) ->payload( 'Reply to a message' ) ->xml(); print_r( $xml );
wctp-ClientQuery
Create an XML representation of the wctp-ClientQuery operation.
use NotifiUs\WCTP\XML\ClientQuery; $clientQuery = new ClientQuery(); $xml = $clientQuery ->senderID( 'senderID' ) ->recipientID( 'recipientID' ) ->trackingNumber( 'trackingNumber' ) ->xml(); print_r( $xml ); /* SimpleXMLElement Object ( [@attributes] => Array ( [wctpVersion] => WCTP-DTD-V1R3 ) [wctp-ClientQuery] => SimpleXMLElement Object ( [@attributes] => Array ( [senderID] => senderID [recipientID] => recipientID [trackingNumber] => trackingNumber ) ) ) */
wctp-VersionQuery
Create an XML representation of the wctp-VersionQuery operation.
use NotifiUs\WCTP\XML\VersionQuery; $versionQuery = new VersionQuery(); $xml = $versionQuery ->inquirer( 'inquirer' ) ->dateTime( Carbon::now() ) ->xml();
You can also leave off optional parameters like this:
//dateTime is an optional parameter $xml = $versionQuery ->inquirer( 'inquirer' ) ->xml();
License
The php-wctp library is open-source software licensed under the MIT license.
Testing
After cloning the repository and running composer install, you can run the test suite:
vendor/bin/phpunit
Static Analysis
Run PHPStan to check for type and logic errors:
vendor/bin/phpstan analyse
Security Vulnerabilities
If you discover a security vulnerability, please email support@calltheory.com.
All security vulnerabilities will be promptly addressed.
notifius/php-wctp 适用场景与选型建议
notifius/php-wctp 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 489 次下载、GitHub Stars 达 2, 最近一次更新时间为 2019 年 08 月 31 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「php」 「xml」 「wctp」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 notifius/php-wctp 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 notifius/php-wctp 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 notifius/php-wctp 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Load DOM document safety
Added a method to Laravel response for handling xml response and also converting Eloquent return to XML.
Uses reflection to map XML to PHP objects.
Xml Template Engine
Alfabank REST API integration
RESTful API server for structured and self-documenting resources over JSON, XML, ...
统计信息
- 总下载量: 489
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 2
- 点击次数: 14
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2019-08-31