Static Public Member Functions | |
| static | getCustomTransactionStatus ($auth, $custom_ticket, $sentTo= '') |
| static | getTransactionStatus ($auth, $transaction_ticket_id, $sentTo= '') |
| static | sendMessage ($auth, $message, $recipientList=array(), $custom_ticket= '', $status_url= '') |
| static | sendMessageSpecifyLocale ($auth, $message, $recipientList=array(), $custom_ticket= '', $status_url= '') |
| static | sendTemplateMessage ($auth, $template, $recipientList=array(), $custom_ticket= '', $status_url= '') |
| static getCustomTransactionStatus | ( | $ | auth, |
| $ | custom_ticket, | ||
| $ | sentTo = '' |
||
| ) | [static] |
Description:
| WSAuthentication | $auth | Authentication Object username - String[40] (Required) - Username for company credentials password - String[40] (Required) - Password for company credentials api_key - String[40] (Required) - Credentials for company code - Integer (Required) - Default shortcode or longcode for keyword keyword - String[40] (Required) - Default keyword for the group |
| string | $custom_ticket | Custom Ticket custom_ticket - String (Required) - Custom ID that was created in the message |
| string | $sentTo | Send To sendTo - String (Optional) - Phone number with country code the message was sent to. |
sendTo - Phone number message was sent to. status_code - Status code of the message delivery, see Status Codes page for more information status_message - Message that correlates to status code result - True/False
<?php $wsdl = 'SSL//HOST_URL/webservices/?version=2.0.0&wsdl'; $soap = new SoapClient($wsdl); //create an authentication object $auth = array(); $auth['username'] = 'api_username'; $auth['password'] = 'api_password'; $auth['api_key'] = 'xxxxxxxxxxxxxx'; $auth['keyword'] = 'group_keyword'; $auth['code'] = "12345"; $auth = & php_xmlrpc_encode($auth); $msg->addparam($auth); //add custom transaction ticket id $customtransactionticket = "99999999"; //must inclde country code, area code, and phone number, FIELD NOT REQUIRED $sentTo = "15555555"; $results = $soap->getCustomTransactionStatus($auth, $customtransactionticket, $sentTo); print_r($results); if ($results->result == 0 || $results->error > 0) { //error processing throw new Exception($results->message); } else { //after success processing }
SOAP Request
<soapenv:Envelope
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:urn="urn:webservices2_0_0">
<soapenv:Header/>
<soapenv:Body>
<urn:getCustomTransactionStatus soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<auth xsi:type="urn:WSAuthentication">
<!--You may enter the following 6 items in any order-->
<api_key xsi:type="xsd:string">xxxxxxxxxxxxxxxx</api_key>
<keyword xsi:type="xsd:string">keyword</keyword>
<password xsi:type="xsd:string">api_password</password>
<code xsi:type="xsd:string">12345</code>
<username xsi:type="xsd:string">api_username</username>
</auth>
<custom_ticket xsi:type="xsd:string">xxxxxxxxxxxx</custom_ticket>
<sentTo xsi:type="xsd:string">18885554433</sentTo>
</urn:getCustomTransactionStatus>
</soapenv:Body>
</soapenv:Envelope>
SOAP Response
<SOAP-ENV:Envelope SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:ns1="urn:webservices2_0_0"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/">
<SOAP-ENV:Body>
<ns1:getCustomTransactionStatusResponse>
<getCustomTransactionStatusReturn xsi:type="ns1:WSTransactionResponse">
<error_code xsi:type="xsd:int">0</error_code>
<message xsi:type="xsd:string">Successfully retrieved custom transaction status.</message>
<response xsi:type="ns1:WSTransactionList">
<transactionlist SOAP-ENC:arrayType="ns1:WSTransactionDetail[1]" xsi:type="ns1:WSTransactionDetailArray">
<item xsi:type="ns1:WSTransactionDetail">
<sendTo xsi:type="xsd:string">18885554433</sendTo>
<status_code xsi:type="xsd:int">101</status_code>
<status_message xsi:type="xsd:string">Sent to Carrier</status_message>
</item>
</transactionlist>
</response>
<result xsi:type="xsd:boolean">true</result>
</getCustomTransactionStatusReturn>
</ns1:getCustomTransactionStatusResponse>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
//create bind object and set url WS_MessageBinding bind = new WS_MessageBinding(); bind.Url = "SSL//HOST_URL/webservices/message/2.0.0"; //create authentication object WSAuthentication auth = new WSAuthentication(); auth.username = "api_username"; auth.password = "api_password"; auth.api_key = "xxxxxxxxxxxxxx"; auth.keyword = "group_keyword"; auth.shortcode = "12345"; string customtransactiontickeyid = "9999999999"; string sendto = "18885554433"; //make call to webservice using list and template WSTransactionResponse response = bind.getCustomTransactionStatus(auth, customtransactiontickeyid, sendto); //process response if (!response.result) { //handle error label.Text = response.message; } else { //handle success label.Text = response.message; WSTransactionList list = response.response; }
Request SSL//HOST_URL/httppost/nvp?version=2.0.0&method_name=message.getCustomTransactionStatus&username={username}&password={password}&api_key={api_key}&code=12345&keyword={Group Keyword}&phone=18885554433&custom_ticket=1234 Response <?xml version="1.0" encoding="utf-8"?> <getCustomTransactionStatus> <message>Successfully retrieved custom transaction status.</message> <error_code></error_code> <result>true</result> <response> <transactionlist> <item> <sendTo>18885554433</sendTo> <status_code>101</status_code> <status_message>Sent to Carrier</status_message> </item> </transactionlist> </response> </getCustomTransactionStatus>
| static getTransactionStatus | ( | $ | auth, |
| $ | transaction_ticket_id, | ||
| $ | sentTo = '' |
||
| ) | [static] |
Description:
| WSAuthentication | $auth | Authentication Object username - String[40] (Required) - Username for company credentials password - String[40] (Required) - Password for company credentials api_key - String[40] (Required) - Credentials for company code - Integer (Required) - Default shortcode or longcode for keyword keyword - String[40] (Required) - Default keyword for the group |
| string | $transaction_ticket_id | Transaction Ticket ID transaction_ticket_id - String (Required) - Generated ID that is created when a message is sent. |
| string | $sentTo | Send To sendTo - String (Optional) - Phone number with country code the message was sent to. |
sendTo - Phone number message was sent to. status_code - Status code of the message delivery, see Status Codes page for more information status_message - Message that correlates to status code result - True/False
<?php $wsdl = 'SSL//HOST_URL/webservices/?version=2.0.0&wsdl'; $soap = new SoapClient($wsdl); //create an authentication object $auth = array(); $auth['username'] = 'api_username'; $auth['password'] = 'api_password'; $auth['api_key'] = 'xxxxxxxxxxxxxx'; $auth['keyword'] = 'group_keyword'; $auth['code'] = "12345"; //add transaction ticket id $ticket = "99999999"; //must inclde country code, area code, and phone number, FIELD NOT REQUIRED $sentTo = "15555555"; $results = $soap->getTransactionStatus($auth, $ticket, $sentTo); print_r($results); if ($results->result == 0 || $results->error > 0) { //error processing throw new Exception($results->message); } else { //after success processing }
SOAP Request
<soapenv:Envelope
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:urn="urn:webservices2_0_0">
<soapenv:Header/>
<soapenv:Body>
<urn:getTransactionStatus soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<auth xsi:type="urn:WSAuthentication">
<!--You may enter the following 6 items in any order-->
<api_key xsi:type="xsd:string">xxxxxxxxxxxxxxxx</api_key>
<keyword xsi:type="xsd:string">keyword</keyword>
<password xsi:type="xsd:string">api password</password>
<code xsi:type="xsd:string">12345</code>
<username xsi:type="xsd:string">api username</username>
</auth>
<transaction_ticket_id xsi:type="xsd:string">xxxxxxxxxxxx</transaction_ticket_id>
<sentTo xsi:type="xsd:string">18885554433</sentTo>
</urn:getTransactionStatus>
</soapenv:Body>
</soapenv:Envelope>
SOAP Response
<SOAP-ENV:Envelope SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:ns1="urn:webservices2_0_0"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/">
<SOAP-ENV:Body>
<ns1:getTransactionStatusResponse>
<getTransactionStatusReturn xsi:type="ns1:WSTransactionResponse">
<message xsi:type="xsd:string">Successfully retrieved transaction status.</message>
<response xsi:type="ns1:WSTransactionList">
<transactionlist SOAP-ENC:arrayType="ns1:WSTransactionDetail[1]" xsi:type="ns1:WSTransactionDetailArray">
<item xsi:type="ns1:WSTransactionDetail">
<sendTo xsi:type="xsd:string">18885554433</sendTo>
<status_code xsi:type="xsd:int">101</status_code>
<status_message xsi:type="xsd:string">Sent to Carrier</status_message>
</item>
</transactionlist>
</response>
<result xsi:type="xsd:boolean">true</result>
</getTransactionStatusReturn>
</ns1:getTransactionStatusResponse>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
//create bind object and set url WS_MessageBinding bind = new WS_MessageBinding(); bind.Url = "SSL//HOST_URL/webservices/message/2.0.0"; //create authentication object WSAuthentication auth = new WSAuthentication(); auth.username = "api_username"; auth.password = "api_password"; auth.api_key = "xxxxxxxxxxxxxx"; auth.keyword = "group_keyword"; auth.code = "12345"; string transactiontickeyid = "9999999999"; string sendto = "18885554433"; //make call to webservice using list and template WSTransactionResponse response = bind.getTransactionStatus(auth, transactiontickeyid, sendto); //process response if (!response.result) { //handle error label.Text = response.message; } else { //handle success label.Text = response.message; WSTransactionList list = response.response; }
Request SSL//HOST_URL/httppost/nvp?version=2.0.0&method_name=message.getTransactionStatus&username={username}&password={password}&api_key={api_key}&code=12345&keyword={Group Keyword}&transaction_ticket_id=1323184090575&phone=18885554433 Response <?xml version="1.0" encoding="utf-8"?> <getTransactionStatus> <message>Successfully retrieved transaction status.</message> <error_code></error_code> <result>true</result> <response> <transactionlist> <item> <sendTo>18885554433</sendTo> <status_code>100</status_code> <status_message>Delivered</status_message> </item> </transactionlist> </response> </getTransactionStatus>
| static sendMessage | ( | $ | auth, |
| $ | message, | ||
| $ | recipientList = array(), |
||
| $ | custom_ticket = '', |
||
| $ | status_url = '' |
||
| ) | [static] |
Description:
| WSAuthentication | $auth | Authentication Object username - String[40] (Required) - Username for company credentials password - String[40] (Required) - Password for company credentials api_key - String[40] (Required) - Credentials for company code - Integer (Required) - Default shortcode or longcode for keyword keyword - String[40] (Required) - Default keyword for the group, division or company that the message will be sent to, unless you provide a recipientList then you must only provide a group keyword. |
| string | $message | Message message - String[160] (Required) - Message to be sent (160 character max length) |
| WSRecipientList | $recipientList | Recipient List sendTo - String (Required) - Phone number with country code, email or landline the message will be sent to. type - Integer (Required) - 1 = SMS, 2 = SMS Email Gateway, 3 = Text To Voice, 4 = Email, 5 = Text Number, 6 = Invalid Address carrier - Integer[4] (Optional) - If you pass the carrier id of the phone number this will bypass the phone lookup. |
| string | $custom_ticket | Custom Ticket custom_ticket - String[50] (Optional) - This is a custom ID you can create and with it you can use the getCustomTransactionStatus function to check the delivery status of a message. |
| string | $status_url | Status URL status_url - String[500] (Optional) - Status URL that can be used to post the information to a file Click HERE for more information about the Status URL. |
custom_ticket - Custom ticket id result - True/False whether the call was successful or not transaction_ticket - ID created from message, this can be used in the getTransactionStatus function to check the delivery status of the message
<?php $wsdl = 'SSL//HOST_URL/webservices/?version=2.0.0&wsdl'; $soap = new SoapClient($wsdl); //create an authentication object $auth = array( "username" => 'api_username', "password" => 'api_password', "api_key" => 'api_key', "code" => '12345', "keyword" => 'Group Keyword', ); //the keyword can be a company, division, or group (default or custom) keyword. //If the keyword is a company or division, no recipient list can be passed in. The message will be sent to all subscribers in the company or division. //If the keyword is a group keyword then a recipient can be passed, but not required. If no list is provided, the message will be sent to all subscribers to the group. $message = 'Test message'; $list = array(); $list['recipients'][] = array('sendTo'=>'18885554433','type'=>'1', 'carrier' => '', 'customfields' => ''); $list['recipients'][] = array('sendTo'=>'test@test.com','type'=>'4', 'carrier' => '', 'customfields' => ''); $custom_ticket = 'Custom ticket id goes here'; $status_url = 'Status URL goes here'; $results = $soap->sendMessage($auth, $message, $list, $custom_ticket, $status_url); print_r($results); if ($results->result == 0 || $results->error > 0) { //error processing throw new Exception($results->message); } else { //after success processing }
SOAP Request <soapenv:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:urn="urn:webservices2_0_0" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"> <soapenv:Header/> <soapenv:Body> <urn:sendMessage soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"> <auth xsi:type="urn:WSAuthentication"> <!--You may enter the following 5 items in any order--> <api_key xsi:type="xsd:string">api_key</api_key> <code xsi:type="xsd:string">12345</code> <keyword xsi:type="xsd:string">Compay, Division, or Group keyword</keyword> <password xsi:type="xsd:string">api_password</password> <username xsi:type="xsd:string">api_username</username> </auth> <message xsi:type="xsd:string">Test Message</message> <recipientList xsi:type="urn:WSRecipientList"> <recipients xsi:type="urn:WSRecipientArray" soapenc:arrayType="urn:WSRecipient[]"> <recipient> <sendTo>18885554433</sendTo> <type>1</type> </recipient> </recipients> </recipientList> <custom_ticket xsi:type="xsd:string">xxxxxxxxxxxx</custom_ticket> <status_url xsi:type="xsd:string">Status URL</status_url> </urn:sendMessage> </soapenv:Body> </soapenv:Envelope> SOAP Response <SOAP-ENV:Envelope SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="urn:webservices2_0_0" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"> <SOAP-ENV:Body> <ns1:sendMessageResponse> <sendMessageReturn xsi:type="ns1:WSMessageResponse"> <custom_ticket xsi:type="xsd:string">xxxxxxxxxxxx</custom_ticket> <error_code xsi:type="xsd:int">0</error_code> <message xsi:type="xsd:string">Message request received.</message> <result xsi:type="xsd:boolean">true</result> <transaction_ticket xsi:type="xsd:string">1317852383161</transaction_ticket> </sendMessageReturn> </ns1:sendMessageResponse> </SOAP-ENV:Body> </SOAP-ENV:Envelope>
api.WS_MessageBinding bind = new WS_APP.api.WS_MessageBinding(); bind.Url = "SSL//HOST_URL/webservices/message/2.0.0"; api.WSAuthentication auth = new WS_APP.api.WSAuthentication(); auth.api_key = "api_key"; auth.username = "api_username"; auth.password = "api_password"; auth.code = "12345"; auth.keyword = "Group Keyword"; String message = "This is an api send message test."; //api.WSRecipientList recipients = new WS_APP.api.WSRecipientList(); List<WS_APP.api.WSRecipient> recipients = new List<WS_APP.api.WSRecipient>(); api.WSRecipient recipient = new WS_APP.api.WSRecipient(); recipient.sendTo = "18885554433"; recipient.type = 1; recipients.Add(recipient); recipient = new WS_APP.api.WSRecipient(); recipient.sendTo = "test@test.com"; recipient.type = 4; recipients.Add(recipient); api.WSRecipientList list = new WS_APP.api.WSRecipientList(); list.recipients = recipients.ToArray(); String custom_ticket = ""; String status_url = ""; api.WSMessageResponse response = new WS_APP.api.WSMessageResponse(); response = bind.sendMessage(auth, message, list, custom_ticket, status_url); //check to see if there was an error if (!response.result) { //handle errors } else { //handle successful response }
Request SSL//HOST_URL/httppost?phone=18885554433,18885554422&username={username}&password={password}&api_key={api_key}&code=12345&keyword={Group Keyword}&message=testMessage <!-- Keep phone lists to a maximum of 100 phone numbers per http post --> Response <?xml version="1.0" encoding="utf-8"?> <sendMessageSpecifyNumbers> <message>2 message sent</message> <result>true</result> <response> <item> <item> <item>18885554433</item> </item> <item> <item>18885554422</item> </item> </item> <item>1331653646357</item> </response> </sendMessageSpecifyNumbers>
| static sendMessageSpecifyLocale | ( | $ | auth, |
| $ | message, | ||
| $ | recipientList = array(), |
||
| $ | custom_ticket = '', |
||
| $ | status_url = '' |
||
| ) | [static] |
Description:
| WSAuthentication | $auth | Authentication Object username - String[40] (Required) - Username for company credentials password - String[40] (Required) - Password for company credentials api_key - String[40] (Required) - Credentials for company code - Integer (Required) - Default shortcode or longcode for keyword keyword - String[40] (Required) - Default keyword for the group, division or company that the message will be sent to, unless you provide a recipientList then you must only provide a group keyword. |
| string | $message | Message message - String[70 - 160] (Required) - Base message to be sent. If the message is in a language other than english then the max length of the message can be 70 characters, otherwise it can be 160 character max length |
| WSRecipientEnhancedList | $recipientList | Recipient List sendTo - String (Required) - Phone number with country code, email or landline the message will be sent to. type - Integer (Required) - 1 = SMS, 2 = SMS Email Gateway, 3 = Text To Voice, 4 = Email, 5 = Text Number, 6 = Invalid Address carrier - Integer[4] (Optional) - If you pass the carrier id of the phone number this will bypass the phone lookup. country - String (Optional) - This is to specify the country of the recipient locale - String (Optional) - This is where you can set the language/destination of the message. If the message you provide is in any other language than english (US-EN) you must provide the locale so we can provide the correct encoding. message - String[70 - 160] (Optional) - If a message is provided in the recipient object then it will bypass the original message and send this one. This is a way to provide personal messags for each recipient. If the message is in a language other than english then the max length of the message can only be 70 characters, otherwise it can be 160 character max length. customField - Object (Optional) - This object holds a name value pairing. This can be used to map specific information for each recipient. |
| string | $custom_ticket | Custom Ticket custom_ticket - String[50] (Optional) - This is a custom ID you can create and with it you can use the getCustomTransactionStatus function to check the delivery status of a message. |
| string | $status_url | Status URL status_url - String[500] (Optional) - Status URL that can be used to post the information to a file Click HERE for more information about the Status URL. |
custom_ticket - Custom ticket id result - True/False whether the call was successful or not transaction_ticket - ID created from message, this can be used in the getTransactionStatus function to check the delivery status of the message
<?php $wsdl = 'SSL//HOST_URL/webservices/?version=2.0.0&wsdl'; $soap = new SoapClient($wsdl); //create an authentication object $auth = array( "username" => 'api_username', "password" => 'api_password', "api_key" => 'api_key', "code" => '12345', "keyword" => 'Group Keyword', ); //the keyword must be a group keyword. $message = 'Base Test Message'; $fields = array(); $fields[] = array('name'=>'name','value'=>'John'); $fields[] = array('name'=>'amount','value'=>'43.30'); $list = array(); $list['recipients'][] = array( 'sendTo'=>'18885554433', 'type'=>'1', 'carrier' => '', 'country' => 'BR', 'locale' => 'PT-BR', 'message' => 'Isto é uma mensagem em português', 'customfields' => $fields ); $list['recipients'][] = array( 'sendTo'=>'test@test.com', 'type'=>'4', 'carrier' => '', 'country' => 'BR', 'locale' => 'PT-BR', 'message' => 'Isto é uma mensagem em português', 'customfields' => $fields ); $custom_ticket = 'Custom ticket id goes here'; $status_url = 'Status URL goes here'; $results = $soap->sendMessageSpecifyLocale($auth, $message, $list, $custom_ticket, $status_url); print_r($results); if ($results->result == 0 || $results->error > 0) { //error processing throw new Exception($results->message); } else { //after success processing }
SOAP Request <soapenv:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:urn="urn:webservices2_0_0" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"> <soapenv:Header/> <soapenv:Body> <urn:sendMessageSpecifyLocale soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"> <auth xsi:type="urn:WSAuthentication"> <!--You may enter the following 5 items in any order--> <api_key xsi:type="xsd:string">api_key</api_key> <code xsi:type="xsd:string">1234567890</code> <keyword xsi:type="xsd:string">Compay, Division, or Group keyword</keyword> <password xsi:type="xsd:string">api_password</password> <username xsi:type="xsd:string">api_username</username> </auth> <message xsi:type="xsd:string">Base Test Message</message> <recipientList xsi:type="urn:WSRecipientEnhancedList"> <recipients xsi:type="urn:WSRecipientEnhancedArray" soapenc:arrayType="urn:WSRecipientEnhanced[]"> <recipient> <sendTo>18885554433</sendTo> <type>1</type> <country>BR</country> <locale>PT-BR</locale> <message>Isto é uma mensagem em português</message> <customfields> <customfield> <name>name</name> <value>John Doe</value> </customfield> <customfield> <name>loan</name> <value>$4,000</value> </customfield> </customfields> </recipient> </recipients> </recipientList> <custom_ticket xsi:type="xsd:string">xxxxxxxxxxxx</custom_ticket> <status_url xsi:type="xsd:string">Status URL</status_url> </urn:sendMessageSpecifyLocale> </soapenv:Body> </soapenv:Envelope> SOAP Response <SOAP-ENV:Envelope SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="urn:webservices2_0_0" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"> <SOAP-ENV:Body> <ns1:sendMessageResponse> <sendMessageReturn xsi:type="ns1:WSMessageResponse"> <custom_ticket xsi:type="xsd:string">xxxxxxxxxxxx</custom_ticket> <error_code xsi:type="xsd:int">0</error_code> <message xsi:type="xsd:string">Message request received.</message> <result xsi:type="xsd:boolean">true</result> <transaction_ticket xsi:type="xsd:string">1317852383161</transaction_ticket> </sendMessageReturn> </ns1:sendMessageResponse> </SOAP-ENV:Body> </SOAP-ENV:Envelope>
api.WS_MessageBinding bind = new WS_APP.api.WS_MessageBinding(); bind.Url = "SSL//HOST_URL/webservices/message/2.0.0"; api.WSAuthentication auth = new WS_APP.api.WSAuthentication(); auth.api_key = "api_key"; auth.username = "api_username"; auth.password = "api_password"; auth.code = "12345"; auth.keyword = "Group Keyword"; String message = "This is an api send message test."; List<WS_APP.api.WSRecipientEnhanced> recipients = new List<WS_APP.api.WSRecipientEnhanced>(); api.WSRecipientEnhanced recipient = new WS_APP.api.WSRecipientEnhanced(); recipient.sendTo = "18885554433"; recipient.type = 1; recipient.message = "Isto é uma mensagem em português"; recipient.country = "BR"; recipient.locale = "PT-BR"; //create custom fields for recipient List<WS_APP.api.WSCustomField> fields = new List<WS_APP.api.WSCustomField>(); api.WSCustomField field = new WS_APP.api.WSCustomField(); field.name = "name"; //will replace {name} in templace with "field.value" field.value = "John"; fields.Add(field); field = new WS_APP.api.WSCustomField(); field.name = "amount"; //will replace {amount} in template with "field.value" field.value = "43.50"; fields.Add(field); //add custom fields to recipient object recipient.customfields = fields.ToArray(); recipients.Add(recipient); recipient1 = new WS_APP.api.WSRecipientEnhanced(); recipient1.sendTo = "test@test.com"; recipient1.type = 4; recipient1.message = "Isto é uma mensagem em português"; recipient1.country = "BR"; recipient1.locale = "PT-BR"; //create custom fields for recipient List<WS_APP.api.WSCustomField> fields = new List<WS_APP.api.WSCustomField>(); api.WSCustomField field = new WS_APP.api.WSCustomField(); field.name = "name"; //will replace {name} in templace with "field.value" field.value = "John"; fields.Add(field); field = new WS_APP.api.WSCustomField(); field.name = "amount"; //will replace {amount} in template with "field.value" field.value = "43.50"; fields.Add(field); //add custom fields to recipient object recipient1.customfields = fields.ToArray(); recipients.Add(recipient1); api.WSRecipientEnhancedList list = new WS_APP.api.WSRecipientEnhancedList(); list.recipients = recipients.ToArray(); String custom_ticket = ""; String status_url = ""; api.WSMessageResponse response = new WS_APP.api.WSMessageResponse(); response = bind.sendMessageSpecifyLocale(auth, message, list, custom_ticket, status_url); //check to see if there was an error if (!response.result) { //handle errors } else { //handle successful response }
| static sendTemplateMessage | ( | $ | auth, |
| $ | template, | ||
| $ | recipientList = array(), |
||
| $ | custom_ticket = '', |
||
| $ | status_url = '' |
||
| ) | [static] |
Description:
| WSAuthentication | $auth | Authentication Object username - String[40] (Required) - Username for company credentials password - String[40] (Required) - Password for company credentials api_key - String[40] (Required) - Credentials for company code - Integer (Required) - Default shortcode or longcode for keyword keyword - String[40] (Required) - Default keyword for the group that the message will be tied to. |
| WSTemplate | $template | Template Object id - String (Optional) - ID of the template title - String (Optional) - Title of the template subject - String (Optional) - Subject of the template text - String[160] (Required) - Actual message of the template description - String (Optional) - Added description or note of the template |
| WSRecipientList | $recipientList | Recipient List sendTo - String (Required) - Phone number with country code, email or landline the message will be sent to. type - Integer (Required) - 1 = SMS, 2 = SMS Email Gateway, 3 = Text To Voice, 4 = Email, 5 = Text Number, 6 = Invalid Address carrier - Integer[4] (Optional) - If you pass the carrier id of the phone number this will bypass the phone lookup. customField - Object (Optional) - This object holds a name value pairing. This can be * used to map specific information for each recipient. |
| string | $custom_ticket | Custom Ticket custom_ticket - String[50] (Optional) - Custom id that can be created to use with getCustomTransactionStatus to check the delivery status of a message |
| string | $status_url | Status URL status_url - String[500] (Optional) - Status URL that can be used to post the information to a file Click HERE for more information about the Status URL. |
custom_ticket - Custom ticket id result - True/False whether the call was successful or not transaction_ticket - ID created from message, this can be used in the getTransactionStatus function to check the delivery status of the message
Code Examples:
<?php $wsdl = 'SSL//HOST_URL/webservices/?version=2.0.0&wsdl'; $soap = new SoapClient($wsdl); //create an authentication object $auth = array( "username" => 'api_username', "password" => 'api_password', "api_key" => 'api_key', "code" => '12345', "keyword" => 'Group Keyword', ); // add template $template = array('text'=>'Hey {name}, you still owe {amount:0.00} on your bill!', 'description'=>'','id'=>'4534', 'subject'=>'','title'=>''); //or //$template = array('id'=>'792'); // add recipient list //$fields = array('name'=>'John','amount'=>'43.30'); $fields = array(); $fields[] = array('name'=>'name','value'=>'John'); $fields[] = array('name'=>'amount','value'=>'43.30'); $sendTo = array(); $sendTo[] = array('sendTo'=>'18885554433','type'=>'1','customfields'=>$fields, 'carrier' => ''); $recipients = array(); $recipients['recipients'] = $sendTo; $custom_ticket = 'Custom Ticket Goes Here'; $status_url = 'Status URL Goes Here'; $results = $soap->sendTemplateMessage($auth, $template, $recipients, $custom_ticket, $status_url); print_r($results); if ($results->result == 0 || $results->error > 0) { //error processing throw new Exception($results->message); } else { //after success processing }
SOAP Request <soapenv:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:urn="urn:webservices2_0_0" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"> <soapenv:Header/> <soapenv:Body> <urn:sendTemplateMessage soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"> <auth xsi:type="urn:WSAuthentication"> <!--You may enter the following 6 items in any order--> <api_key xsi:type="xsd:string">xxxxxxxxxxxxxxx</api_key> <keyword xsi:type="xsd:string">Company, Division or Group keyword</keyword> <password xsi:type="xsd:string">api_password</password> <code xsi:type="xsd:string">12345</code> <thread xsi:type="xsd:boolean">1</thread> <username xsi:type="xsd:string">api_username</username> </auth> <recipientList xsi:type="urn:WSRecipientList"> <recipients xsi:type="urn:WSRecipientArray" soapenc:arrayType="urn:WSRecipient[]"> <recipient> <sendTo>18885554433</sendTo> <type>1</type> <customfields> <customfield> <name>name</name> <value>John Doe</value> </customfield> <customfield> <name>loan</name> <value>$4,000</value> </customfield> </customfields> </recipient> </recipients> </recipientList> <template xsi:type="urn:WSTemplate"> <!--You may enter the following 5 items in any order--> <id xsi:type="xsd:string">655</id> <description xsi:type="xsd:string">Template Description</description> <subject xsi:type="xsd:string">Template Subject</subject> <text xsi:type="xsd:string">Hey, {name} your loan of {loan} has been approved.</text> <title xsi:type="xsd:string">Template Title</title> </template> <custom_ticket xsi:type="xsd:string">xxxxxxxx</custom_ticket> <status_url xsi:type="xsd:string">Status URL</status_url> </urn:sendTemplateMessage> </soapenv:Body> </soapenv:Envelope> SOAP Response <SOAP-ENV:Envelope SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="urn:webservices2_0_0" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"> <SOAP-ENV:Body> <ns1:sendTemplateMessageResponse> <sendTemplateMessageReturn xsi:type="ns1:WSMessageResponse"> <custom_ticket xsi:type="xsd:string">xxxxxxxx</custom_ticket> <error_code xsi:type="xsd:int">0</error_code> <message xsi:type="xsd:string">Template Message request received.</message> <result xsi:type="xsd:boolean">true</result> <transaction_ticket xsi:type="xsd:string">1317854008496</transaction_ticket> </sendTemplateMessageReturn> </ns1:sendTemplateMessageResponse> </SOAP-ENV:Body> </SOAP-ENV:Envelope>
//do something amazing within your application api.WS_MessageBinding bind = new WS_APP.api.WS_MessageBinding(); bind.Url = "SSL//HOST_URL/webservices/message/2.0.0"; api.WSAuthentication auth = new WS_APP.api.WSAuthentication(); auth.api_key = "api_key"; auth.username = "api_username"; auth.password = "api_password"; auth.code = "12345"; auth.keyword = "Group Keyword"; api.WSTemplate template = new WS_APP.api.WSTemplate(); //template.text = "Hey {name}, you still owe ${amount} on your loan!"; // OR template.id = "792"; //api.WSRecipientList recipients = new WS_APP.api.WSRecipientList(); List<WS_APP.api.WSRecipient> recipients = new List<WS_APP.api.WSRecipient>(); api.WSRecipient recipient = new WS_APP.api.WSRecipient(); recipient.sendTo = "18885554433"; recipient.type = 1; //create custom fields for recipient List<WS_APP.api.WSCustomField> fields = new List<WS_APP.api.WSCustomField>(); api.WSCustomField field = new WS_APP.api.WSCustomField(); field.name = "name"; //will replace {name} in templace with "field.value" field.value = "John"; fields.Add(field); field = new WS_APP.api.WSCustomField(); field.name = "amount"; //will replace {amount} in template with "field.value" field.value = "43.50"; fields.Add(field); //add custom fields to recipient object recipient.customfields = fields.ToArray(); //add recipient object to list of recipients recipients.Add(recipient); // add recipient list to recipient list object api.WSRecipientList list = new WS_APP.api.WSRecipientList(); list.recipients = recipients.ToArray(); String custom_ticket = ""; String status_url = ""; api.WSMessageResponse response = new WS_APP.api.WSMessageResponse(); response = bind.sendTemplateMessage(auth, template, list, custom_ticket, status_url); //check to see if there was an error if (!response.result) { //handle errors } else { //handle successful response }