API-X is a token-based API that authenticates a sub-account using a token. To send a message using OrgDS API-X, the required parameters that must be submitted to the Base URL are cmd (whose value is equal to send) token, message, recipients, and sender. Other optional parameters are shown in the following sample link and parameter description table.
http://orgds.org/api?token=APIX_xxxxxxxx&cmd=send&message=MESSAGE&recipient=23480xxxxxxxx,23470xxxxxxxx,23490xxxxxxxx&sender=SenderID&type=0&route=0&display=plain
Parameters and Descriptions
Schedule Message
To schedule a message for delivery in the future, add schedule variable to the HTTP request and set its value to a datetime in the format YYYY-MM-DD HH:MM
http://orgds.org/api?token=APIX_xxxxxxxx&cmd=send&message=MESSAGE&recipient=23480xxxxxxxx,23470xxxxxxxx,23490xxxxxxxx&sender=SENDERID&type=0&route=0&schedule=2019-06-20 22:10
Sample API-X Message Submission PHP Code
<?php //cURL function that sends either HTTP POST or HTTP GET request function postData($baseurl, $dataArray = array(),$httpmethod = 'post') { $buildData = http_build_query($dataArray); $ch = curl_init(); if (strtolower($httpmethod)=='get') { $geturl = $baseurl.'?'.$buildData; curl_setopt($ch, CURLOPT_URL, $geturl); } else{ curl_setopt($ch, CURLOPT_URL, $baseurl); // Enable the post response curl_setopt($ch, CURLOPT_POST, true); // The data to transfer with the response curl_setopt($ch, CURLOPT_POSTFIELDS, $buildData); } curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); $response = curl_exec($ch); curl_close($ch); return $response; } //Send a message via API-X //receive form data if(isset($_REQUEST['message'])) { $token = 'APIX_TOKEN'; $cmd = "send"; $message = "This is a sample message content."; $recipient = "234803xxxxxxx,44702xxxxxxxx,01703xxxxxxxx,234903xxxxxxx"; $sender = "SenderID"; $type = 0; $route = 2; $display = "json";//maybe plain or json or xml //set API base URL $baseurl = "https://orgds.org/api"; //convert message data to array $dataArray = array( 'cmd' => $cmd, 'token' => $token, 'recipient' => $recipient, 'sender' => $sender, 'message' => $message, 'type' => $type, 'route' => $route, 'display' => $display ); //process message sending // $httpmethod value maybe either post or get $reply = postData($baseurl, $dataArray,$httpmethod = 'post'); /* * $reply stores the response gotten from the API * The response format is determined by the value supplied to the display variable, which maybe plain or json or xml. * The default display format is plain text. * See the response codes and formats in the documentation */ } ?>
Response Codes & Formats
After a message has been successfully sent, a reply will be returned based on the supplied display format.
Plain Response Format
600: Message sent/scheduled successfully
Plain text response shows only a response code and its description. Other formats described below show detailed information about the message. See possible response messages and error codes here.
JSON Response Format
{ "responseCode":600, "info":"Message sent\/scheduled successfully", "smsPages":1, "recipients":"234802xxxxxxx,234903xxxxxxx,234705xxxxxxx", "msgRoute":"BasicPlus", "msgType":"Plain", "basicNumbers":"234802xxxxxxx", "corporateNumbers":"234903xxxxxxx,234705xxxxxxx", "unitsBefore":"61.65", "unitsUsed":"4.70", "creditBalance":56.95, "messageId":"c73bb503634c1475b0c04813aca62bcd" }
XML Response Format
<message> <responseCode>600</responseCode> <info>Message sent/scheduled successfully</info> <smsPages>1</smsPages> <recipients>234802xxxxxxx,234903xxxxxxx,234705xxxxxxx</recipients> <msgRoute>BasicPlus</msgRoute> <msgType>Plain</msgType> <basicNumbers>234802xxxxxxx</basicNumbers> <corporateNumbers>234903xxxxxxx,234705xxxxxxx</corporateNumbers> <unitsBefore>61.65</unitsBefore> <unitsUsed>4.70</unitsUsed> <creditBalance>56.95</creditBalance> <messageId>c73bb503634c1475b0c04813aca62bcd</messageId> </message>