A PHP library for creating and submitting XML WCTP requests and responses
Not ready for every day use! We will tag a version 1.0.0 when we're ready for you to use in production. For now, expect namespace updates and other breaking changes.
Install the library using composer:
composer require notifius/php-wctp
Example use of library:
use NotifiUs\WCTP\XML\ClientQuery;
$clientQuery = new ClientQuery();
$xml = $clientQuery
->senderID( 'senderID' )
->recipientID( 'recipientID' )
->trackingNumber( 'trackingNumber' )
->xml();
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 | ✓ |
We rely on the nesbot/carbon
composer package for handling dates throughout our library.
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.
The $xml
variable will be a SimpleXMLElement Object. You can get the XML as a string by calling $xml->asXML()
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.
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 );
/*
*/
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
)
)
)
*/
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();
The php-wctp library is open-source software licensed under the MIT license.
After cloning the repository and running composer install
, you can run the test suite like this:
vendor/bin/phpunit --bootstrap vendor/autoload.php tests/
If you discover a security vulnerability, please send an e-mail to support@notifi.us. All security vulnerabilities will be promptly addressed.