The following code will help to send SMS in PHP Using SMSGatewayCenter API before to go we need account at SMSGatewayCenter then place your credential in following code.
#index.php
<?php
$curl = curl_init();
$apikey = 'somerandomkey'; //if you use apikey then userid and password is not required
$userId = 'YourUsername';
$password = 'YourPaswword';
$sendMethod = 'simpleMsg'; //(simpleMsg|groupMsg|excelMsg)
$messageType = 'text'; //(text|unicode|flash)
$senderId = 'SMSGAT';
$mobile = '9199999999999,9199999999998'; //comma separated
$msg = "This is my first message with SMSGatewayCenter";
$scheduleTime = ''; //mention time if you want to schedule else leave blank
curl_setopt_array($curl, array(
CURLOPT_URL => "http://www.smsgateway.center/SMSApi/rest/send",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => "userId=$userId&password=$password&senderId=$senderId&sendMethod=$sendMethod&msgType=$messageType&mobile=$mobile&msg=$msg&duplicateCheck=true&format=json",
CURLOPT_HTTPHEADER => array(
"apikey: $apikey",
"cache-control: no-cache",
"content-type: application/x-www-form-urlencoded"
),
));
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
Place your credentials and run it will work for you. if you don't have account you can create https://www.smsgateway.center/
Key | Value | Description |
---|---|---|
Login Credentials (Required Parameters) | ||
Authenticate your API request using userId-password or apiKey. You should use either one to authenticate your login. | ||
userId | Your Registered Username | The registered username parameter to be passed. You can use this if apiKey is not being used. |
password | Your password | The password needs to be urlencoded if there are any special characters used in the password field. You can use this if apiKey is not being used. |
apiKey | Your unique apiKey | apiKey needs to be sent as HTTP header when you are not using userId and password credentials. You can avail this from your user control panel and use instead of userId and password HTTP Request parameter. Please do not disclose this to anyone. |
Required Parameters | ||
sendMethod | simpleMsg | groupMsg | excelMsg |
simpleMsg: This value required for single or comma separated mobile numbers SMS. groupMsg: This value required for Group SMS option. excelMsg: This value required for Bulk Upload option. |
senderId | Approved Sender Name | For Indian customers, sender name would be of 6 alpha characters. For International customers, sender name depends on country to country basis. senderId parameter is an optional for Promotional Gateway customers. You need not include this parameter if you have opted for promotional gateway. |
msgType | text|unicode | This is to define simple or UNICODE message. For simple English, you can give value as text or for non-English messages, give value as unicode. |
msg | Your text message | This is the message content which you want to send to your clients. View Cost/Count |
Default Parameters (Optional) | ||
format | plain|json|xml | Value for response format. System default is plain. If you need responses in JSON or XML then you have to give value as JSON or XML. |
flashMsg | true|false | Maximum 160 characters allowed in message content. You could send unicode messages too. System default is false. |
duplicateCheck | true|false | Checks and removes Duplicate mobile numbers. System default is true. You can turn off duplicate checking of mobile numbers by giving value as false, duplicate numbers wont be removed. |
scheduleTime | datetime format (YYYY-MM-DD HH:MM:SS) | Value for Scheduling. System default is null. If you want to enable then use this parameter and give value as YYYY-MM-DD HH:MM:SS. |
Simple Message - Single or Bulk (Required for simpleMsg) | ||
mobile | 10 or 12 Digits mobile number. | Mobile number format can be 10 to 12 digits prefix with 0 or 91. Preferred mobile format is prefix with country code 91. You can include single number or comma separated numbers. Maximum comma separated mobile numbers allowed are 1000. While sending Simple message, sendMethod parameter needs to be simpleMsg |
Group Message - Single or Multiple Groups (Required for groupMsg) | ||
group | Group IDs / Group Names. Example: 1123,1321 OR mygroup, othergroup OR 1123,mygroup |
Sending SMS to your saved Contacts grouped by Group Name or Group ID. You can send to single group or multiple groups at once separated by comma. Valid Group IDs or Group names should be mentioned in this parameter. For multiple groups, please separate by comma. While sending Group SMS message, sendMethod parameter needs to be groupMsg |
Bulk Upload (Required for excelMsg) | ||
file | file path | File path to be given of the file. While sending Bulk Upload message, sendMethod parameter needs to be excelMsg |
fileType | csv | xls | xlsx | zip | txt | We allow 5 extensions in bulk upload. Maximum File Size Allowed: 15MB |
DLT (Only for Indian Delivery Network) | ||
dltEntityId | Your DLT's Principal Entity ID | Optional. This is an optional parameter if you have saved your Principal DLT Entity ID in your profile settings. If this is not saved in profile, then this is a mandatory parameter. |
dltTemplateId | Your DLT's Approved Message Template ID | Optional. This is an optional parameter if you have saved your message templates. If this is not saved in message templates, then this is a mandatory parameter. |
Link Tracking | ||
trackLink | true | false | System default is false. Set this to true if you want to enable advanced link tracking. The last URL from your message will be converted to short URL. If you do not use this parameter, the value of this parameter will be false. |
smartLinkTitle | string | Optional. This acts as identifier for your tracking, You can name your smart link title to check insights based on your title. |
Test | ||
testMessage | true | false | System default is false. Set this to true if you want to test our API. Messages wont be delivered and SMS balance wont be deducted. If you do not use this parameter, the value of this parameter will be false. |
SMS Gateway Center Pricing