Rus
Eng
Отправка SMS пользователю на Битрикс

All English-language materials have been translated fully automatically using the Google service

In 2019, 1C-Bitrix has a built-in SMS messaging mechanism, but at the moment there are only three services available: sms.ru, sms assistant and twilio . This article will show you how you can send SMS messages through other services if, for some reason, the above are not suitable for you.

  // Register a user registration event handler
AddEventHandler ("main", "OnBeforeUserRegister", Array ("EventHunter", "OnBeforeUserRegisterHandler"));

class EventHunter {

    // Directly the handler that accepts user fields
    function OnBeforeUserRegisterHandler (& $ arFields) {

        // If registration is successful and the field is filled
        if (($ arFields ['USER_ID']> 0) && (isset ($ arFields ['PERSONAL_PHONE']))) {

            // Form a message
            $ message = "Welcome to the site!";

            // Collect the fields
            $ fields = array (
                'login' => SMSC_LOGIN, // Your login SMS-center
                'psw' => SMSC_PASS, // Your SMS-center password
                'phones' => $ arFields ['PERSONAL_PHONE'], // The Phone field filled in by the user
                'mes' => $ message, // The message to be sent
                'charset' => LANG_CHARSET, // Site encoding
            );

            // Form the URL for sending the request
            $ url = 'https://smsc.ru/sys/send.php?' ... http_build_query ($ fields);

            // Initialize the session
            $ curl = curl_init ($ url);

            curl_setopt ($ curl, CURLOPT_HEADER, 1); // Read the title
            curl_setopt ($ curl, CURLOPT_NOBODY, 1); // Read header without body
            curl_setopt ($ curl, CURLOPT_RETURNTRANSFER, 1); // Do not display

            // Execute the request
            $ result = curl_exec ($ curl);

            // End session
            curl_close ($ curl);
        }
    }
 }  

Reprint of material:

Comments

There are no comments yet, you can be the first to leave it

Leave a comment

The site uses a comment pre-moderation system, so your message will be published only after approval by the moderator

You are replying to a user's comment

Send

FEEDBACK

Email me

Are you developing a new service, making improvements to the existing one and want to be better than your competitors? You have come to the right place. I offer you a comprehensive studio-level website development. From me you can order design, layout, programming, development of non-traditional functionality, implementation of communication between CMS, CRM and Data Analitics, as well as everything else related to sites, except for promotion.

Contact, I will always advise on all questions and help you find the most effective solution for your business. I am engaged in the creation of sites in Novosibirsk and in other regions of Russia, I also work with the CIS countries. You will be satisfied with our cooperation

An error occurred while sending, please try again after a while
Message sent successfully

Phones

+7(993) 007-18-96

Email

info@tichiy.ru

Address

Россия, г. Москва

By submitting the form, you automatically confirm that you have read and accept the Privacy Policy site

Contact with me
Send message
By submitting the form, you automatically confirm that you have read and accept Privacy policy of site
Sending successful!
Thank you for contacting :) I will contact you as soon as possible
Sending failed
An error occurred while sending the request. Please wait and try again after a while or call my phone number