![]() Then we set up some parameters for our cURL object using “curl_setopt()”. We start by initializing our cURL object using “curl_init()” and store it in the variable “$ch”. To do this, we use the cURL library built into PHP. Now our JSON object is ready to be sent to the server. In the next line, we leave “recipients” blank because we fill it in the following line, where we use a for loop that takes each recipient and adds them to our recipient array. Note that if you want to include emojis or special characters, it requires some extra steps, which you can find more information about in our documentation. In the example, I just write “Hello world”. “Message” is of course the content of the SMS. In the example, it automatically says “ExampleSMS”, but you can enter your own name or the desired Sender ID. For example, if you receive an SMS from your bank, the bank’s name will often be the sender. This is the Sender ID that will be displayed on the recipient’s phone. In the next line we have a JSON object, which is the object that sends information to our server about how the SMS should be sent. In the example we use a couple of test numbers, but you can insert up to 10,000 different recipients here.įirst, enter your country code without any zeros or plus signs in front of it. We have “recipients”, which are the phone numbers the message should be sent to. In the code, we also have details about the content of the message. In the fourth line we have your API token, which is used to identify you and your account. In the third line, we have a variable that contains the URL to our endpoint for sending SMS messages. In the first line, we start our PHP file. If this seems straightforward, you can skip to the section where I execute the script. In this section, I will walk you through each step of the code so you understand what it does and how you can customize it to your specific needs. $conn = new mysqli ( $this -> dbHost, $this -> dbUsername, $this -> dbPassword, $this -> dbName ) ĭie( "Failed to connect with MySQL: ".
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |