Easily send or receive an SMS message In php using TextLocal API Integration.
<?php // Account details $apiKey = urlencode('Your apiKey'); // Message details $numbers = array(918123456789, 918987654321); $sender = urlencode('TXTLCL'); $message = rawurlencode('This is your message'); $numbers = implode(',', $numbers); // Prepare data for POST request $data = array('apikey' => $apiKey, 'numbers' => $numbers, "sender" => $sender, "message" => $message); // Send the POST request with cURL $ch = curl_init('https://api.textlocal.in/send/'); curl_setopt($ch, CURLOPT_POST, true); curl_setopt($ch, CURLOPT_POSTFIELDS, $data); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); $response = curl_exec($ch); curl_close($ch); // Process your response here echo $response; ?>
Replace your creadentials like apiKey along with username and password in above script. you can get from here TextLocal
Caution: Some users opt to place their request inside a code loop, while testing we highly recommend setting the test parameter to true, as occasionally an infinite loop can occur and users can consume all their credits very quickly.
|sender||Use this field to specify the sender name which is pre-approved by DLT and Textlocal.
|message||The message content. This parameter should be no longer than 918 characters. See Helpful Information for message length details. The message also must be URL Encoded to support symbols like &.|
|Login Parameters (Additional Information)|
|apiKey||You can create these in your Messenger Control Panel (click here) for each application, and limit the usage of them by host IP Address.|
|numbers||Comma-delimited list of mobile numbers in international format (i.e. 918123456789). Maximum of 10,000 numbers and error code 33 will be returned if exceeded.|
|group_id||This parameter can be used in place of the numbers parameter in order to send to an entire contact group. This parameter should contain the ID of the relevant group, which can found either within Messenger (in the "Reports" - "Advanced Reports" - "List of Group ID's" section) or by running the get_groups command. Additionally group 5 contains "contacts" and group 6 contains "opt-outs".|
|schedule_time||This parameter can be used to specify a schedule date/time for your message, which should be provided in Unix timestamp format. Times should be provided in GMT.|
|receipt_url||Use this field to specify an alternative URL to which the delivery receipt(s) will be sent. See handling receipts documentation.|
|custom||This value will be set against the message batch and will passed back in the delivery receipts. This allows you to match delivery receipts to their corresponding messages.|
|optouts||Can be set to true in order to check against your own opt-outs list and Textlocal's global opt-outs database. Your message will not be sent to numbers within these lists. If not provided defaults to false.|
|validity||Can be set, up to 72 hours in advance, to say after which time, you don't want the message delivered. This should be in a Unix timestamp format.|
|unicode||Set this value to true to specify that your message body will contain unicode characters. See Encoding/Decoding Unicode Documentation|
|tracking_links||Set this value to true to specify that the message contains links and they should be converted to short links (trackable in messenger), Please note that links must be url encoded before being placed into the message|
|test||Set this field to true to enable test mode, no messages will be sent and your credit balance will be unaffected. If not provided defaults to false|