{"id":4809,"date":"2022-07-08T13:19:18","date_gmt":"2022-07-08T11:19:18","guid":{"rendered":"https:\/\/www.smsapi.com\/blog\/?p=4809"},"modified":"2026-01-15T12:21:34","modified_gmt":"2026-01-15T11:21:34","slug":"send-sms-with-php-library","status":"publish","type":"post","link":"https:\/\/www.smsapi.com\/blog\/send-sms-with-php-library\/","title":{"rendered":"Send SMS with PHP (Library, code examples, open SMS API)"},"content":{"rendered":"\n<p><strong>This article\u2019s sole purpose is to quickly show you how to send SMS using PHP.<\/strong><\/p>\n\n\n\n<!--more-->\n\n\n\n<h2 class=\"wp-block-heading\">Send SMS Using PHP: A Step-By-Step Guide<\/h2>\n\n\n\n<p>If you&#8217;re a developer looking to incorporate SMS functionality into your PHP applications, you&#8217;re in the right place. With the SMS API in PHP, you can seamlessly integrate SMS capabilities into your web or mobile apps. Whether you need to send one-time verification codes, notifications, or promotional messages, using a reliable short message service gateway simplifies the process. By leveraging PHP, a popular server-side scripting language, you can create dynamic and interactive SMS-driven experiences for your users.<\/p>\n\n\n\n<p>See how to send bulk SMS messages, customize content and schedule messaging in one of the most popular programming languages for applications, websites. Nothing less, nothing more than a well-documented SMS API for business communication.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">SMS API: PHP Library<\/h2>\n\n\n\n<p>We have been developing our PHP library since 2013. A stable, reliable and open API allows us to provide developers with a wide range of tools. Most of them are ready to use straight from the box, our <a rel=\"noreferrer noopener\" href=\"https:\/\/www.smsapi.com\/docs\/\" target=\"_blank\">Documentation<\/a>. No need to write every tiny detail by yourself, right? This is probably the easiest (and the most secure) way to use the <a rel=\"noreferrer noopener\" href=\"https:\/\/www.smsapi.com\/en\/bulk-sms\" target=\"_blank\">bulk SMS messaging<\/a> platform. Let\u2019s send some text messages using PHP!<\/p>\n\n\n\n<figure class=\"wp-block-embed is-type-wp-embed is-provider-smsapi-blog wp-block-embed-smsapi-blog\"><div class=\"wp-block-embed__wrapper\">\n<blockquote class=\"wp-embedded-content\" data-secret=\"sxlK40my62\"><a href=\"https:\/\/www.smsapi.com\/blog\/api-smsapi-essentials-developer-guide\/\">Send SMS using API \u2013 Developer Guide #01<\/a><\/blockquote><iframe loading=\"lazy\" class=\"wp-embedded-content\" sandbox=\"allow-scripts\" security=\"restricted\" style=\"position: absolute; clip: rect(1px, 1px, 1px, 1px);\" title=\"&#8220;Send SMS using API \u2013 Developer Guide #01&#8221; &#8212; SMSAPI Blog\" src=\"https:\/\/www.smsapi.com\/blog\/api-smsapi-essentials-developer-guide\/embed\/#?secret=v4cLSCsBFe#?secret=sxlK40my62\" data-secret=\"sxlK40my62\" width=\"600\" height=\"338\" frameborder=\"0\" marginwidth=\"0\" marginheight=\"0\" scrolling=\"no\"><\/iframe>\n<\/div><\/figure>\n\n\n\n<p>Yet before we go any further, keep in mind that you can always fall back to the API. It has everything you might need to at least start with a professional A2P SMS communication channel. Furthermore, there are also practical examples in different languages, like C#, Bash, and Python. PHP is one such implementation.<\/p>\n\n\n\n<div class=\"wp-block-buttons is-content-justification-center is-layout-flex wp-container-core-buttons-is-layout-16018d1d wp-block-buttons-is-layout-flex\">\n<div class=\"wp-block-button is-style-secondary\"><a class=\"wp-block-button__link wp-element-button\" href=\"https:\/\/www.smsapi.com\/en\/sms-api\" target=\"_blank\" rel=\"noreferrer noopener\">SMS API Libraries<\/a><\/div>\n<\/div>\n\n\n\n<p>If you wish to look closely at the Library, its uses and other details, <a rel=\"noreferrer noopener\" href=\"https:\/\/github.com\/smsapi\" target=\"_blank\" class=\"ek-link\">visit the SMSAPI PHP repository on GitHub<\/a>. As usual, the source code is probably the best source of knowledge, offering insight into all functionalities. Were you looking for a more pragmatic approach? Stick around. I\u2019ll go in-depth on everything you need to start sending SMS with PHP from web.<\/p>\n\n\n\n<p>Sending SMS messages using PHP is a powerful way to engage with your audience. In this step-by-step guide, I&#8217;ll walk you through the process of sending SMS messages from your PHP application. Send SMS using PHP and automate notifications, alerts, or marketing campaigns.<\/p>\n\n\n\n<p>I&#8217;ll cover everything from setting up your SMS gateway to crafting and delivering messages programmatically. With just a few lines of code, you&#8217;ll be able to reach your users via SMS, enhancing your application&#8217;s functionality. Learn how to optimize your PHP code for mass messaging while ensuring delivery reliability. From database integration to message scheduling, we&#8217;ll cover the essential techniques for successful bulk SMS messages.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Integrated SMS API in PHP: first steps<\/h2>\n\n\n\n<p>First things first, you&#8217;ll need an access to SMS gateway: SMSAPI account. Furthermore, you better configure it immediately\u2014it&#8217;ll save a hassle later.<\/p>\n\n\n\n<div class=\"wp-block-smsapi-blog-2021-infobox infobox infobox--info post-content--full-width\"><div class=\"infobox__icon\"><img decoding=\"async\" src=\"data:image\/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiIHN0YW5kYWxvbmU9Im5vIj8+CjxzdmcKICAgd2lkdGg9IjEwMCUiCiAgIGhlaWdodD0iMTAwJSIKICAgdmlld0JveD0iMCAwIDEyIDE2IgogICBjbGlwLXJ1bGU9ImV2ZW5vZGQiCiAgIHhtbDpzcGFjZT0icHJlc2VydmUiCiAgIHZlcnNpb249IjEuMSIKICAgaWQ9InN2ZzYzIgogICB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciCiAgIHhtbG5zOnN2Zz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPgogIDxwYXRoCiAgICBzdHlsZT0iZmlsbDogcmdiKDE3LCAxOTIsIDEyOCk7IGZpbGwtcnVsZTogbm9uemVybzsiCiAgIGQ9Im03LjUxNDA1LDExbC0zLDBjMCwtMyAxLjYsLTQgMi43LC00LjZjMC40LC0wLjIgMC43LC0wLjQgMC45LC0wLjZjMC41LC0wLjUgMC4zLC0xLjIgMC4yLC0xLjRjLTAuMywtMC43IC0xLC0xLjQgLTIuMywtMS40Yy0yLjEsMCAtMi41LDEuOSAtMi41LDIuM2wtMywtMC40YzAuMiwtMS43IDEuNywtNC45IDUuNSwtNC45YzIuMywwIDQuMywxLjMgNS4xLDMuMmMwLjcsMS43IDAuNCwzLjUgLTAuOCw0LjdjLTAuNSwwLjUgLTEuMSwwLjggLTEuNiwxLjFjLTAuOSwwLjUgLTEuMiwxIC0xLjIsMnoiCiAgIGlkPSJwYXRoNTkiIC8+CiAgPHBhdGgKICAgIHN0eWxlPSJmaWxsOiByZ2IoMTcsIDE5MiwgMTI4KTsgZmlsbC1ydWxlOiBub256ZXJvOyIKICAgZD0ibTgsMTRjMCwxLjEwNSAtMC44OTUsMiAtMiwyYy0xLjEwNSwwIC0yLC0wLjg5NSAtMiwtMmMwLC0xLjEwNSAwLjg5NSwtMiAyLC0yYzEuMTA1LDAgMiwwLjg5NSAyLDJ6IgogICBpZD0icGF0aDYxIiAvPgo8L3N2Zz4K\"\/><\/div><div class=\"infobox__title\"><h4>How to configure the SMSAPI account<\/h4><\/div><div class=\"infobox__content\">\n<ol class=\"wp-block-list\">\n<li><a rel=\"noreferrer noopener\" href=\"https:\/\/www.smsapi.com\/en\/signup\" target=\"_blank\">Create a SMSAPI account<\/a> \u2013 get it free, with test messages included.<\/li>\n\n\n\n<li><a rel=\"noreferrer noopener\" href=\"https:\/\/ssl.smsapi.com\/react\/payments\/payments-data\" target=\"_blank\">Fill in the company details in the Payments section<\/a> \u2013 don\u2019t worry, <strong>tests are free<\/strong>. We use your data for account verification purposes only.<\/li>\n\n\n\n<li>Once verified, you\u2019ll be granted a free SMS quota and the ability to set your <a rel=\"noreferrer noopener\" href=\"https:\/\/www.smsapi.com\/blog\/sender-id-how-to-send-branded-sms-company-name\/\" target=\"_blank\">SMS sender names<\/a>.<\/li>\n\n\n\n<li>Generate API token. You will use this unique, random 40-character long string to authenticate the connection. The HTTP client sends the authorization request header when accessing a restricted API.<\/li>\n<\/ol>\n\n\n\n<div class=\"wp-block-buttons is-content-justification-center is-layout-flex wp-container-core-buttons-is-layout-16018d1d wp-block-buttons-is-layout-flex\">\n<div class=\"wp-block-button is-style-primary\"><a class=\"wp-block-button__link wp-element-button\" href=\"https:\/\/www.smsapi.com\/en\/signup\">Test SMSAPI<\/a><\/div>\n<\/div>\n<\/div><\/div>\n\n\n\n<h3 class=\"wp-block-heading\">Watch video tutorials and do it yourself<\/h3>\n\n\n\n<figure class=\"wp-block-embed is-type-wp-embed is-provider-smsapi-blog wp-block-embed-smsapi-blog\"><div class=\"wp-block-embed__wrapper\">\n<blockquote class=\"wp-embedded-content\" data-secret=\"2t0WLfueR9\"><a href=\"https:\/\/www.smsapi.com\/blog\/do-it-yourself-customer-portal-walkthrough\/\">Do it yourself #01 &#8211; Customer Portal Walkthrough (video tutorial)<\/a><\/blockquote><iframe loading=\"lazy\" class=\"wp-embedded-content\" sandbox=\"allow-scripts\" security=\"restricted\" style=\"position: absolute; clip: rect(1px, 1px, 1px, 1px);\" title=\"&#8220;Do it yourself #01 &#8211; Customer Portal Walkthrough (video tutorial)&#8221; &#8212; SMSAPI Blog\" src=\"https:\/\/www.smsapi.com\/blog\/do-it-yourself-customer-portal-walkthrough\/embed\/#?secret=ayeMt3bBge#?secret=2t0WLfueR9\" data-secret=\"2t0WLfueR9\" width=\"600\" height=\"338\" frameborder=\"0\" marginwidth=\"0\" marginheight=\"0\" scrolling=\"no\"><\/iframe>\n<\/div><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">Straight to the point: how to send SMS with PHP?<\/h2>\n\n\n\n<p>Relax, I won\u2019t describe every class and method. Though I\u2019ll focus on what I think is entry-level knowledge, you\u2019ll be able to do the rest yourself\u2014starting with <a rel=\"noreferrer noopener\" href=\"https:\/\/www.smsapi.com\/en\/sms-notifications\" target=\"_blank\">the SMS notification system<\/a>. Let\u2019s go!<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"bramka-sms-php\">PHP SMS gateway<\/h3>\n\n\n\n<p>SMS messaging is a core of the SMSAPI gateway. You can implement the message composing and database management however you like, but you will need an SMS API to send the message. How does it work code-wise?<\/p>\n\n\n\n<figure class=\"wp-block-embed is-type-wp-embed is-provider-smsapi-blog wp-block-embed-smsapi-blog\"><div class=\"wp-block-embed__wrapper\">\n<blockquote class=\"wp-embedded-content\" data-secret=\"IV0MlzbNam\"><a href=\"https:\/\/www.smsapi.com\/blog\/sms-gateway-starting-guide\/\">SMS Gateway \u2013 Starting Guide<\/a><\/blockquote><iframe loading=\"lazy\" class=\"wp-embedded-content\" sandbox=\"allow-scripts\" security=\"restricted\" style=\"position: absolute; clip: rect(1px, 1px, 1px, 1px);\" title=\"&#8220;SMS Gateway \u2013 Starting Guide&#8221; &#8212; SMSAPI Blog\" src=\"https:\/\/www.smsapi.com\/blog\/sms-gateway-starting-guide\/embed\/#?secret=7QMX1HzzIQ#?secret=IV0MlzbNam\" data-secret=\"IV0MlzbNam\" width=\"600\" height=\"338\" frameborder=\"0\" marginwidth=\"0\" marginheight=\"0\" scrolling=\"no\"><\/iframe>\n<\/div><\/figure>\n\n\n\n<p>As SMSAPI is a RESTfull API, you must set up an HTTP client to utilize its methods. The PHP code allows you to use the provided libcurl library adapter, so <strong>you don\u2019t have to implement your HTTP client<\/strong>\u2014but if you wish, do so. It\u2019s easier to use the stock solution. Here\u2019s how you can start:<\/p>\n\n\n\n<pre class=\"wp-block-code language-php\"><code>&lt;?php\n\/\/client.php\ndeclare(strict_types=1);\nuse Smsapi\\Client\\Curl\\SmsapiHttpClient;\nrequire_once 'vendor\/autoload.php';\n\n$client = new SmsapiHttpClient();<\/code><\/pre>\n\n\n\n<p>With a client prepped and ready, connect to https:\/\/api.smsapi.com as shown in the second file listing:<\/p>\n\n\n\n<pre class=\"wp-block-code language-php\"><code>&lt;?php\n\/\/service.php\ndeclare(strict_types=1);\nuse Smsapi\\Client\\SmsapiClient;\nrequire_once 'vendor\/autoload.php';\nrequire_once 'client.php';\n\n$apiToken = '%SMSAPI_ACCESS_TOKEN%';\n$service = $client-&gt;smsapiComService($apiToken);<\/code><\/pre>\n\n\n\n<p class=\"language-php\">Two simple lines (not counting the namespace calls) are enough to create <code>SmsapiHttpClient<\/code>&nbsp;and&nbsp;<code>smsapiComService<\/code> objects. This concludes the basic configuration. So far, so good.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"wysylanie-sms-w-php\">SMS messaging via PHP<\/h3>\n\n\n\n<p class=\"language-php\">The <code>SmsFeature<\/code> interface implements SMS messaging. Here are its <strong>key methods<\/strong>:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><code>sendSms(SendSmsBag $sendSmsBag)<\/code> \u2013 send an SMS message to a single contact;<\/li>\n\n\n\n<li><code>sendSmss(SendSmssBag $sendSmssBag)<\/code> \u2013 send SMS messages to multiple contacts.<\/li>\n<\/ul>\n\n\n\n<p>The \u201cBag\u201d type objects determine elements of a text message. Their properties are recipient or recipients, content, and other optional parameters. Find the practical example below:<\/p>\n\n\n\n<pre class=\"wp-block-code language-php\"><code>&lt;?php\n\/\/sendSms.php\ndeclare(strict_types=1);\nuse Smsapi\\Client\\Service\\SmsapiComService;\nuse Smsapi\\Client\\Feature\\Sms\\Bag\\SendSmsBag;\nrequire_once 'service.php';\n\n$smsBag = SendSmsBag::withMessage('44111222333', 'Hello world!');\n$service-&gt;smsFeature()-&gt;sendSms($smsBag);<\/code><\/pre>\n\n\n\n<p class=\"language-php\">The <code>withMessage<\/code>&nbsp;factory method takes <strong>two string arguments<\/strong>: recipient phone number (plus country code) and message body. In a nutshell, sending messages using the PHP is done in four simple steps:<\/p>\n\n\n\n<ol class=\"wp-block-list\" type=\"1\">\n<li>creation of the HTTP client;<\/li>\n\n\n\n<li>connection with the short message service,<\/li>\n\n\n\n<li>definition of a message body and recipient,<\/li>\n\n\n\n<li>message delivery.<\/li>\n<\/ol>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"powiadomienia-sms-w-php-dodatkowe-opcje\">Additional features of PHP SMS notifications<\/h2>\n\n\n\n<p class=\"language-php\">The sendSms method returns the SMS object containing a bunch of helpful information:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><code>$id<\/code> \u2013 id number in SMSAPI;<\/li>\n\n\n\n<li><code>$points<\/code> \u2013 message price presented as the points deducted from your SMSAPI account;<\/li>\n\n\n\n<li><code>$dateSent<\/code> \u2013 time of messaging, UNIX timestamp format;<\/li>\n\n\n\n<li><code>$status<\/code> \u2013 delivery status (<a rel=\"noreferrer noopener\" href=\"https:\/\/www.smsapi.com\/docs\/#17-delivery-statuses\" target=\"_blank\">complete list and explanation<\/a>).<\/li>\n<\/ul>\n\n\n\n<p class=\"language-php\">There\u2019s a huge chance that your SMS communication will depend on <strong>delivering the same messages to many different recipients<\/strong>. Easy-peasy, use the <code>sendSmss<\/code>&nbsp;function and <code>SendSmssBag<\/code> class.<\/p>\n\n\n\n<p>Alternatively, <a rel=\"noreferrer noopener\" href=\"https:\/\/ssl.smsapi.com\/react\/contacts\/groups\" data-type=\"URL\" data-id=\"https:\/\/ssl.smsapi.com\/react\/contacts\/groups\" target=\"_blank\">create groups in the Contacts tab<\/a> and send a bulk <a rel=\"noreferrer noopener\" href=\"https:\/\/www.smsapi.com\/en\/sms-campaigns\" target=\"_blank\">SMS campaign<\/a> like this:<\/p>\n\n\n\n<pre class=\"wp-block-code language-php\"><code>$receivers = &#91;'44111222333','44444555666'];\n$smssBag = SendSmssBag::withMessage($receivers, 'Hello, receivers!');\n$service-&gt;smsFeature()-&gt;sendSmss($smssBag);\n\n$smsToGroupBag = SendSmsToGroupBag::withMessage('group_name', 'Good morning, contact group!');\n$service-&gt;smsFeature()-&gt;sendSmsToGroup($smsToGroupBag);<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"czas-sie-liczy-planowanie-sms\">Timely messaging \u2013 SMS scheduling<\/h3>\n\n\n\n<p>The message scheduling feature will be essential for larger repeatable campaigns. After all, repetition draws attention. But to do it right, you must <strong>determine the proper time and frequency<\/strong> first. Thus I recommend A\/B tests to find your sweet spot!<\/p>\n\n\n\n<figure class=\"wp-block-embed is-type-wp-embed is-provider-smsapi-blog wp-block-embed-smsapi-blog\"><div class=\"wp-block-embed__wrapper\">\n<blockquote class=\"wp-embedded-content\" data-secret=\"6hAyPmNxt6\"><a href=\"https:\/\/www.smsapi.com\/blog\/how-to-schedule-sms-campaign\/\">How to Schedule an SMS Campaign Online?<\/a><\/blockquote><iframe loading=\"lazy\" class=\"wp-embedded-content\" sandbox=\"allow-scripts\" security=\"restricted\" style=\"position: absolute; clip: rect(1px, 1px, 1px, 1px);\" title=\"&#8220;How to Schedule an SMS Campaign Online?&#8221; &#8212; SMSAPI Blog\" src=\"https:\/\/www.smsapi.com\/blog\/how-to-schedule-sms-campaign\/embed\/#?secret=RVsMt0TqH7#?secret=6hAyPmNxt6\" data-secret=\"6hAyPmNxt6\" width=\"600\" height=\"338\" frameborder=\"0\" marginwidth=\"0\" marginheight=\"0\" scrolling=\"no\"><\/iframe>\n<\/div><\/figure>\n\n\n\n<p>The PHP to send SMS notifications comes with multiple schedule functions. As expected, the API will unfailingly deliver messages at a designated time for you, so <strong>you don\u2019t have to implement such a program yourself<\/strong>. <\/p>\n\n\n\n<p>The code below presents it in three ways as mentioned earlier: single message, bulk campaign and messages sent to a contact group:<\/p>\n\n\n\n<pre class=\"wp-block-code language-php\"><code>$sendingDate = new DateTime('2027-06-30');\n$scheduleSmsBag = ScheduleSmsBag::withMessage(\n\t$sendingDate, \n\t'44111222333', \n\t'An SMS is never late, nor is it early. It arrives precisely when it means to.');\n$smsFeature-&gt;scheduleSms($scheduleSmsBag);\n\n$scheduleSmssBag = ScheduleSmssBag::withMessage(\n\t$sendingDate, \n\t&#91;'44111222333', '44444555666'], \n\t'An SMS is never late, nor is it early. It arrives precisely when it means to.');\n$smsFeature-&gt;scheduleSmss($scheduleSmssBag);\n\n$scheduleSmsToGroupBag = ScheduleSmsToGroupBag::withMessage(\n\t$sendingDate, \n\t'group_name', \n\t'An SMS is never late, nor is it early. It arrives precisely when it means to.');\n$smsFeature-&gt;scheduleSmsToGroup($scheduleSmsToGroupBag);<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"personalizacja-sms-w-bibliotece-php-parametry-i-szablony\">SMS personalization in PHP library: parameters and message templates<\/h3>\n\n\n\n<p>If you are thinking about a bulk SMS campaign, you should also be thinking about <a rel=\"noreferrer noopener\" href=\"https:\/\/www.smsapi.com\/en\/personalization\" target=\"_blank\">content personalization<\/a>. Otherwise, you would be sending the same message to every recipient. And you can do better than that! Use the following two static methods for every \u201cBag\u201d type object to be personal and, not to mention, way more effective.<\/p>\n\n\n\n<p class=\"language-php\">The first method, namely <code>setParams(array $params)<\/code>, allows you to <strong>use any of the following parameters<\/strong>: <code>$param1<\/code>, <code>$param2<\/code>, <code>$param3<\/code>, <code>$param4<\/code>. These are additional properties for the Bag class. Function\u2019s argument is a key array (<code>[%1%]<\/code>, <code>[%2%]<\/code>, <code>[%3%<\/code>], <code>[%4%]<\/code>) that will be replaced with the values &#8216;1&#8217;, &#8216;2&#8217;, &#8216;3&#8217;, &#8216;4&#8217; in the message body. Here\u2019s a code snippet:<\/p>\n\n\n\n<pre class=\"wp-block-code language-php\"><code>$receivers = &#91;'44111222333','44444555666'];\n$params = &#91;\n\t1 =&gt; &#91;'Suzy', 'Barbra'],\n\t2 =&gt; &#91;'London', 'Innsmouth'],\n];\n$smssBag = SendSmssBag::withMessage(\n\t$receivers, \n\t'Hello &#91;%1%] from &#91;%2%]!'\n);\n$smssBag-&gt;setParams($params);\n$service-&gt;smsFeature()-&gt;sendSmss($smssBag);<\/code><\/pre>\n\n\n\n<p class=\"language-php\">The second method, <code>withTemplateName(string&nbsp;$receiver,&nbsp;string&nbsp;$template)<\/code>, allows you to use <a rel=\"noreferrer noopener\" href=\"https:\/\/ssl.smsapi.com\/react\/sms-templates\" target=\"_blank\">templates created in the Customer Portal<\/a>. It is convenient because you can change message content on the fly without changes to your PHP code. The SMS template might look like this:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>PackageSentTemplate:&nbsp;<em>Hi [%1%]! Your order is on its way!<\/em><\/li>\n\n\n\n<li>PackageArrivesTodayTemplate:&nbsp;<em>Hi [%1%]! Your order will arrive today!<\/em><\/li>\n<\/ul>\n\n\n\n<p>And messaging like this:<\/p>\n\n\n\n<pre class=\"wp-block-code language-php\"><code>$params = &#91;1 =&gt; 'Adam'];\n$smsBag = SendSmsBag::withTemplateName(\n\t'44111222333', \n\t'PackageSentTemplate'\n);\n$smsBag-&gt;setParams($params);\n$service-&gt;smsFeature()-&gt;sendSms($smsBag);\n\n$smsBag = SendSmsBag::withTemplateName(\n\t'44111222333', \n\t'PackageArrivesTodayTemplate'\n);\n$smsBag-&gt;setParams($params);\n$service-&gt;smsFeature()-&gt;sendSms($smsBag);<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"dalsza-personalizacja-tresci-sms-dzieki-bazie-kontaktow\">Further content personalization using a contact database<\/h3>\n\n\n\n<p>One way to improve your text message is to deliver relevant information to each recipient. The PHP library can access and use the database to <strong>automatically personalize the content<\/strong> of your messages. Hence there\u2019s no need to put the recipient\u2019s data in the PHP script. SMSAPI has a function to browse and filter a database with an e-mail address, etc. This allows you to send messages containing user-specific data, like the one below about a reservation:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>TableReservationTemplate:&nbsp;<em>Hello [%name%]! Your table at Embers will be ready at [%1%]. Our chief recommends a liver with some fava beans and a nice Chianti!<\/em><\/li>\n<\/ul>\n\n\n\n<p>Here\u2019s how to personalize SMS in PHP:<\/p>\n\n\n\n<pre class=\"wp-block-code language-php\"><code>use Smsapi\\Client\\Service\\SmsapiComService;\nuse Smsapi\\Client\\Feature\\Sms\\Bag\\SendSmsBag;\nuse Smsapi\\Client\\Feature\\Contacts\\Bag\\FindContactsBag;\nuse Smsapi\\Client\\Feature\\Contacts\\ContactsFeature;\nrequire_once 'service.php';\n\n$receiverEmail = '1234@example.com';\n$reservationTime = '19:00';\n\n$contactFindBag = new FindContactsBag();\n$contactFindBag-&gt;email = $receiverEmail;\n$foundContacts =\n\t$service-&gt;contactsFeature()-&gt;findContacts($contactFindBag);\n\n$smsBag = SendSmsBag::withTemplateName(\n\t$foundContacts&#91;0]-&gt;phoneNumber,\n\t'TableReservationTemplate'\n);\n$smsBag-&gt;setParams(&#91;1=&gt;$reservationTime]);\n$service-&gt;smsFeature()-&gt;sendSms($smsBag);<\/code><\/pre>\n\n\n\n<p class=\"language-php\">An e-mail or any other information can help you retrieve a phone number, then personalize a message and send an SMS. For example, the <code>[%name%]<\/code> field will be replaced with the actual name of your customer from the contact database. Refer to the Documentation for <a rel=\"noreferrer noopener\" href=\"https:\/\/www.smsapi.com\/docs\/#sms-messages-to-numbers-from-contacts-database-group\" target=\"_blank\">further information on personalized SMS messages<\/a>.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">PHP SMS API: Enhance User Engagement<\/h3>\n\n\n\n<p>Incorporating a PHP SMS API into your applications is a game-changer for user engagement. With the short message service center, you can create a dynamic user experience. Harness the power of the SMS API in PHP to trigger SMS alerts based on user actions, such as account activities or in-app events. By integrating PHP and an SMS API, you can keep your users informed, drive conversions, and enhance overall satisfaction with your application.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">SMS sender PHP\u2019s ready. What\u2019s next?<\/h2>\n\n\n\n<p>Go to <a rel=\"noreferrer noopener\" href=\"https:\/\/github.com\/smsapi\" target=\"_blank\">GitHub<\/a> if you are looking for the source code for project. You will find language-specific SMSAPI libraries for Java, C#, Python, bash, and JavaScript clients there.<\/p>\n\n\n\n<p>This introduction focuses on the small portion of possible applications of the PHP script. There\u2019s a lot more, and most can be found in <a rel=\"noreferrer noopener\" href=\"https:\/\/github.com\/smsapi\/smsapi-php-client\/tree\/master\/src\/Feature\" target=\"_blank\">the Feature folder<\/a>, e.g.:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>multi-factor authentication (MFA)<\/strong> to make the logins more secure;<\/li>\n\n\n\n<li><strong>contact database management<\/strong> \u2013 add, edit and delete contacts and contact groups;<\/li>\n\n\n\n<li><strong>the cut.li link shortener<\/strong> tool;<\/li>\n\n\n\n<li><strong>account balance checkup<\/strong> \u2013 get remaining points for outgoing messages in PHP.<\/li>\n<\/ul>\n\n\n\n<p>Lastly, check <a rel=\"noreferrer noopener\" href=\"https:\/\/github.com\/smsapi\/smsapi-php-client\/tree\/master\/tests\/\" target=\"_blank\">the test folder<\/a> when needing more interfaces and methods examples. Good luck!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>This article\u2019s sole purpose is to quickly show you how to send SMS using PHP.<\/p>\n","protected":false},"author":21,"featured_media":5282,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[18],"tags":[20,39],"class_list":["post-4809","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-tutorial","tag-english","tag-api"],"_links":{"self":[{"href":"https:\/\/www.smsapi.com\/blog\/wp-json\/wp\/v2\/posts\/4809","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.smsapi.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.smsapi.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.smsapi.com\/blog\/wp-json\/wp\/v2\/users\/21"}],"replies":[{"embeddable":true,"href":"https:\/\/www.smsapi.com\/blog\/wp-json\/wp\/v2\/comments?post=4809"}],"version-history":[{"count":25,"href":"https:\/\/www.smsapi.com\/blog\/wp-json\/wp\/v2\/posts\/4809\/revisions"}],"predecessor-version":[{"id":5911,"href":"https:\/\/www.smsapi.com\/blog\/wp-json\/wp\/v2\/posts\/4809\/revisions\/5911"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.smsapi.com\/blog\/wp-json\/wp\/v2\/media\/5282"}],"wp:attachment":[{"href":"https:\/\/www.smsapi.com\/blog\/wp-json\/wp\/v2\/media?parent=4809"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.smsapi.com\/blog\/wp-json\/wp\/v2\/categories?post=4809"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.smsapi.com\/blog\/wp-json\/wp\/v2\/tags?post=4809"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}