This command can be used to send text messages to either individual numbers or entire contact groups.
- <?php
- include "getpost-lib.php";
- $name = $_REQUEST["name"];
- $message = $_REQUEST["message"];
- $mobileNumber=$_REQUEST["number"];
- $email=$_REQUEST["email"];
- $message="Hi ".$name." we received your request. from number is: ".$mobileNumber." and from email ".$email;
- $senderId="sender";
- $serverUrl="serverUrl";
- $authKey="yourAuthkey";
- $route="1";
- echo sendsmsGET($mobileNumber,$senderId,$route,$message,$serverUrl,$authKey);
- ?>
- <?php
- include "getpost-lib.php";
- $name = $_REQUEST["name"];
- $message = $_REQUEST["message"];
- $mobileNumber=$_REQUEST["number"];
- $email=$_REQUEST["email"];
- $message="Hi ".$name." we received your request. from number is: ".$mobileNumber." and from email ".$email;
- $senderId="sender";
- $route="1";
- $serverUrl="serverUrl";
- $authKey="yourAuthkey";
- echo sendsmsPOST($mobileNumber,$senderId,$route,$message,$serverUrl,$authKey);
- ?>
- <?php
- function sendsmsGET($mobileNumber,$senderId,$route,$message,$serverUrl,$authKey)
- {
- $getData = 'authkey=' .$authKey.'&mobileNos='.$mobileNumber.'&message='.urlencode($message).'&senderId='.$senderId.'&route='.$route;
- //API URL
- $url="http://".$serverUrl."/rest/services/sendSMS/sendGroupSms?AUTH_KEY=".$authKey."&"3.$getData;
- // init the resource
- $ch = curl_init();
- curl_setopt_array($ch, array(
- CURLOPT_URL => $url,
- CURLOPT_RETURNTRANSFER => true,
- CURLOPT_SSL_VERIFYHOST => 0,
- CURLOPT_SSL_VERIFYPEER => 0
- ));
- //get response
- $output = curl_exec($ch);
- //Print error if any
- if(curl_errno($ch))
- {
- echo 'error:' . curl_error($ch);
- }
- curl_close($ch);
- return $output;
- }
- function sendsmsPOST($mobileNumber,$senderId,$route,$message,$serverUrl,$authKey)
- {
- //Prepare you post parameters
- $postData = array(
- 'authkey' => $authKey,
- 'mobileNumbers' => $mobileNumber,
- "groupId" => "0",
- 'smsContent' => $message,
- 'senderId' => $senderId,
- 'route' => $route,
- "smsContentType" =>'english'
- );
- $data_json = json_encode($postData);
- $url="http://".$serverUrl."/rest/services/sendSMS/sendGroupSms?AUTH_KEY=".$authKey;
- // init the resource
- $ch = curl_init();
- curl_setopt_array($ch, array(
- CURLOPT_URL => $url,
- CURLOPT_HTTPHEADER => array('Content-Type: application/json','Content-Length: ' . strlen($data_json)),
- CURLOPT_RETURNTRANSFER => true,
- CURLOPT_POST => true,
- CURLOPT_POSTFIELDS => $data_json,
- CURLOPT_SSL_VERIFYHOST => 0,
- CURLOPT_SSL_VERIFYPEER => 0
- ));
- //get response
- $output = curl_exec($ch);
- //Print error if any
- if(curl_errno($ch))
- {
- echo 'error:' . curl_error($ch);
- }
- curl_close($ch);
- return $output;
- }
- ?>
- <?php
- define("AUTH_KEY", "1b34cf67c6546ed7734c6aa568d45b0");
- function sendsms($mobileNumber,$senderId,$route,$message)
- //Your authentication key
- $authKey = AUTH_KEY;
- $route = "default";
- $getData = 'authkey=' .$authKey.'&mobiles='.$mobileNumber.'&message='.$message.'&sender='.$senderId.'&route='.$route;
- $url="http://msg.msgclub.net/rest/services/sendSMS/sendGroupSms"."?".$getData;
- // init the resource
- $ch = curl_init();
- curl_setopt_array($ch, array(
- CURLOPT_URL => $url,
- CURLOPT_RETURNTRANSFER => true,
- ));
- $output=curl_exec($ch);
- curl_close($ch);
- return $output;
- }
- <?>
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 | If you have a promotional account, do not send this parameter. If you have a transactional account, use this field to specify the sender name for your message. Sender name must be 6 alpha characters and should be pre-approved by Textlocal. In the absence of approved sender names, use the default 'TXTLCL' | |||
message | The message content. This parameter should be no longer than 766 characters. See Helpful Information for message length details. The message also must be URL Encoded to support symbols like &. | |||
Login Parameters (Additional Information) | ||||
username | The email address used to log into Textlocal. | |||
hash | Your secure hash can be found within Messenger in the main navigation under "Help->All Documentation". Alternatively you can use the password parameter instead and use your Textlocal password in plain text. | |||
Optional Parameters | ||||
apiKey | This can be used instead of the username/hash/password. You can create them 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). | |||
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. | |||
unicode | Set this value to true to specify that your message body will contain unicode characters. See Encoding/Decoding Unicode Documentation | |||
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 |
Error Codes | Description |
3001 * | for Success |
3002 * | Invalid URL |
3003 * | Invalid User/Password |
3004 * | Invalid Message Type |
3005 * | Invalid Message |
3006 * | Invalid Destination |
3007 * | Invalid Source |
3008 * | Invalid DLR Field |
3009 * | Authentication Failed |
3010 * | Internal Error |
3011 * | Insufficient Balance |
3012 * | Responce Time Out |
3013 * | Invalid Request Content Type |
3014 * | Missing Mobile Number |
3015 * | SMs Content for Approval |
3016 * | Missing Required Parameter |
3017 * | FAIL |
3018 * | Expired Account |
3019 * | Null Pointer Exception code |
3020 * | Empty User Name |
3021 * | Empty Password |
3022 * | User Name not Available |
3023 * | Session Expired |
3024 * | Already Exist |
3025 * | Empty Group Name |
3026 * | Empty Contact Name |
3027 * | Empty Mobile Number |
3028 * | Empty Group Id |
3029 * | Empty City Name |
3030 * | Empty Occupation |
3041 * | Empty E-Mail Id |
3042 * | Group not Exist |
3043 * | Empty Message |
3044 * | Empty Route Id |
3045 * | Empty Sender Id |
3047 * | Empty Draft Id |
3048 * | Empty First Name |
3049 * | Empty Last Name |
3050 * | Empty Balance |
3051 * | Empty Role Id |
3052 * | For User Name Length |
3053 * | Empty Expiry Date/td> |
3054 * | Invalid Date |
3055 * | Empty Client Id |
3056 * | Invalid Status |
3057 * | Empty Country Name |
3058 * | Empty State Name |
3059 * | Session Expired |
3060 * | Empty Date |
3061 * | Access Denied |
3062 * | Empty Old Password |
3063 * | Password not Maching |
3064 * | Empty SMS |
3065 * | Empty Amount |
3066 * | Empty Address |
3067 * | Empty RequestId |
3068 * | Empty Group and MobileNo |
3069 * | Empty Description |
3070 * | Fail to Change RoleId |
3071 * | Empty CallerId |
3072 * | Empty File URL and Draft |
3073 * | Empty Duration |
3074 * | Invalid Request |
3075 * | Invalid Aoudio file |
3076 * | Missing Upload File |
Warning Codes | ||||
3 | Invalid number. |