You are viewing an older version of this page.
Open current versionTransactional message (PHP SDK 1.0)
The BulkGate\Sms\Message class represents the object of the SMS message, which consists of the content of the message and the recipient.
Recipient
The class accepts as the first argument a phone number that can be entered by a string:
or accepts an instance of the object `Message\PhoneNumber`:
You can also enter the phone number after creating an instance of the object using the method phoneNumber($phone_number, $iso = null):
To obtain a phone number, you can use the method getPhoneNumber(), which always returns an instance of the `Message\PhoneNumber` object.
Text of the message
The second parameter is the input of the text of the message. There are also 2 options where the first is to enter text using a string, and the other is an instance of the class `Message\Text`.
Of course, you can define text even after creating an instance of an object using the method text($text, array $variables = [])
You can use the getText() method, to retrieve the message text, which always returns an instance of the `Message\Text` object.
JSON Support
The BulkGate\Sms\Message object implements the \JsonSerializable interface that lets you convert it via the json_encode() to JSON format.
The output is:
The status, price, credit and id keys are filled in only after sending,
scheduled once you call schedule().
Convert to string
The BulkGate\Sms\Message object implements the magic method __string()
The output is:
Convert to array
Fluent interface
Fluent interface is the technique of chaining methods.
Information after posting
After you send the message, you can get the price, status, and the message id from the message.
Scheduling the message
The schedule() method sets the time of sending as a Unix timestamp. Without a
parameter it cancels the scheduling.
Thank you for your feedback.