BulkGate Helpdesk
  • Languages iconEnglish
    • Čeština

›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

PHP/SDK v2

  • PHP/SDK v2

Bulk SMS (Campaign)

The class BulkGate\Sms\BulkMessage represents the object, which connects BulkGate\Sms\Message type of messages to a bulk message (campaign).

use BulkGate\Sms\BulkMessage;

The constructor has one optional array type parameter that must contain BulkGate\Sms\Message items.

$array = [
    new BulkGate\Sms\Message("447971700001", "test1"),
    new BulkGate\Sms\Message("447971700002", "test2"),
    new BulkGate\Sms\Message("447971700003", "test3"),
    new BulkGate\Sms\Message("447971700004", "test4"),
];

$bulk_message = new BulkMessage($array);

Messages can be added one at a time:

$message = new BulkGate\Sms\Message(
    new BulkGate\Sms\Message\PhoneNumber("7971700001", BulkGate\Sms\Country::UNITED_KINGDOM),
    new BulkGate\Sms\Message\Text("test<number>", [
        'number' => '5'
    ])
);

/** @var BulkGate\Sms\BulkMessage $bulk_message */
$bulk_message->addMessage(message);

Iterator

You can browse through messages using the foreach cycle

/** 
 * @var BulkGate\Sms\BulkMessage $bulk_message 
 * @var BulkGate\Sms\Message $message
 */
foreach($bulk_message as $message)
{
    echo $message;
}

You can find out the number of messages using count()

/** @var BulkGate\Sms\BulkMessage $bulk_message */
$bulk_message->count();

JSON Support

The BulkGate\Sms\BulkMessage object implements the \JsonSerializable interface that lets you convert it via the json_encode() function to JSON format.

/** @var BulkGate\Sms\BulkMessage $bulk_message */
echo json_encode($bulk_message);

The output is:

[
  {
    "number": {
      "number": "447971700001",
      "iso": null,     
    },
    "text": "test1",
    "id": null,
    "price": 0.0,
    "status": "preparation"
  },
  {
    "number": {
      "number": "447971700002",
      "iso": null
    },
    "text": "test2",
    "id": null,
    "price": 0.0,
    "status": "preparation"
  },
  {
    "number": {
      "number": "447971700003",
      "iso": null
    },
    "text": "test3",
    "id": null,
    "price": 0.0,
    "status": "preparation"
  },
  {
    "number": {
      "number": "447971700004",
      "iso": null
    },
    "text": "test4",
    "id": null,
    "price": 0.0,
    "status": "preparation"
  },
  {
    "number": {
      "number": "7971700005",
      "iso": "gb"
    },
    "text": "test5",
    "id": null,
    "price": 0.0,
    "status": "preparation"
  }
]

Convert to string

The BulkGate\Sms\BulkMessage object implements the magic method __string().

/** @var BulkGate\Sms\BulkMessage $bulk_message */
$message = (string) $bulk_message; // into the variable
echo $bulk_message; // to the output

Output is:

447971700001: test1
447971700002: test2
447971700003: test3
447971700004: test4
797170000ř: test5

Convert to array

/** @var BulkGate\Sms\BulkMessage $bulk_message */
$array = $message->toArray();
← Transactional messageText of the message →
  • Iterator
  • JSON Support
  • Convert to string
  • Convert to array
SolutionsSMS GatewayViber for BusinessBroadcastBulk SMSSMS NotificationsTwo-way 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. © 2025