BulkGate Helpdesk
  • Languages iconEnglish
    • Czech

›Message

Installation

  • Installation
  • Installation to Nette framework

API Administration

  • API administration & tokens

Message

  • Transactional message
  • Bulk SMS (Campaign)
  • Text of the message
  • Phone Number

Sender type

  • Setting sender type

Sender service

  • Sender Service

Other

  • Country

Delivery confirmations and incoming SMS

  • Delivery confirmations and incoming SMS
  • Bulk delivery confirmation of incoming SMS

Phone Number

The BulkGate\Sms\Message\PhoneNumber class represents the phone number object.

use BulkGate\Sms\Message\PhoneNumber;

The constructor accepts the required parameter phone number and optional country ISO code.

$phone_number = new PhoneNumber(
    "420777777777", 
    BulkGate\Sms\Country::UNITED_KINGDOM
);

The second parameter is required if you enter a number in the national format. If you enter a phone number in the national format and don't enter the ISO 3166-1 alpha-2 code, BulkGate will fill the international prefix according to the country listed in your user account.

You can also change the phone number after creating an instance.

/** @var BulkGate\Sms\Message\PhoneNumber $phone_number */
$phone_number->phoneNumber('447971700001');

You can also set the ISO code.

/** @var BulkGate\Sms\Message\PhoneNumber $phone_number */
$phone_number->iso(BulkGate\Sms\Country::UNITED_KINGDOM);

// nebo

$phone_number->iso('gb');

In case of invalid ISO code, an exception BulkGate\Sms\Message\InvalidPhoneNumberException is called

Convert to JSON

/** @var BulkGate\Sms\Message\PhoneNumber $phone_number */
echo json_encode($phone_number);

The output is:

{
    "number": "447971700001",
    "iso": null
}

Other

Obtain a formatted phone number in a string

/** @var BulkGate\Sms\Message\PhoneNumber $phone_number */
$phone_number->getPhoneNumber();
$number = (string) $phone_number; 
echo $phone_number;

Obtaining an ISO code

/** @var BulkGate\Sms\Message\PhoneNumber $phone_number */
$phone_number->getIso(); // returns a string or null

It also supports fluent interface

/** @var BulkGate\Sms\Message\PhoneNumber $phone_number */
$phone_number
    ->phoneNumber('7971700001')
    ->iso(BulkGate\Sms\Country::UNITED_KINGDOM);
← PreviousNext →
  • Convert to JSON
  • Other
SolutionsSMS GatewayViber for BusinessBroadcastBulk SMSSMS NotificationsTwo-way SMSSmart SMSMobile ConnectWeb Portal
Partners & DevelopersSMS APIIntegrationsAffiliate programWhite label
SourcesBlogYouTubeFacebookLinkedInTwitterGitHubPackagist
CompanyContactPrivacyTerms and Conditions
Price listsPrice list SMSPrice list ViberPrice list Mobile Connect
SMS GatewayTOPefekt s.r.o. © 2022