Copyright 2008 Tagga Media Inc All rights Reserved
The Send Message API function allows the developer to send an SMS text message to a user by specifying the mobile number and message text. The Send Message API function can be called via HTTP POST, which must contain the first five parameters specified below. The SMS text message is only sent to the intended mobile user if said user has opted in to receive SMS from developer. See the section on OPT-IN rules for more details. Successfully sent messages will result in the mobile user receiving a message containing up to 100 characters of developer specified message and 40 characters of an ad message appended to the end. If the message is marked as paid (developer must register payment at tagga.com to use paid flag), the user will receive a message containing up to 140 characters of developer specified message with no ad.
POST URL:
http://tagga.com/api/send/
POST Parameters:
Restrictions:
Response:
An XML response is returned and details a unique transaction ID, response code, and response message. You are responsible for checking the response message and acting appropriately.
For a developer to be able to send to a user, the user must opt in to receive messages from the developer. To opt in to messages from a developer, the user must text the developer's keyword to 82442. This means that the developer will need to advertise this fact to the user (ex. Text TEAM to 82442 to get schedule updates). At the time of opt in, tagga will send the user a notification message letting them know that they have opted in. The message will also contain instructions on how to opt out. Users will be able to opt out by texting the developers keyword and then UNSUB (ex. Text TEAM UNSUB to unsubscribe from schedule updates).
Repeated Sends to an Opted Out User:
If an end user opts out and the developer attempts to send them an SMS, they will receive return code = 1 (Invalid Recipient - Not on allowed recipient list). The developer is responsible for deleting or marking the account in their database as 'opted out'. If tagga receives more than 5 requests for a user who has opted out, the developer account may be suspended.
$postdata = http_build_query(
array(
'apikey' => 'abc123', // put your API key here
'passkey' => '321cba', // put your API password key here
'tagg' => 'sometagg', // the tagg you have reserved for this application
'mobile' => '16045551234', // the user's mobile number
'message' => 'This is the message I want to send to a subscribed user.'
)
);
$opts = array(
'http' => array(
'method' => 'POST',
'header' => 'Content-type: application/x-www-form-urlencoded',
'content' => $postdata
)
);
$context = stream_context_create($opts);
$response = file_get_contents(
'http://tagga.com/api/send/',
false,
$context
);
// handle the response message
import urllib
apikey = u'abc123' # put your API key here
passkey = u'321cba' # put your API password key here
tagg = u'sometagg' # the tagg you have reserved for this application
mobile = u'16045551234' # the user's mobile number
message = u'This is the message I want to send to a subscribed user.'
postdata = urllib.urlencode({'apikey': apikey, 'passkey': passkey, 'tagg': tagg, 'mobile': mobile, 'message': message})
response = urllib.urlopen('http://tagga.com/api/send/', postdata)
# handle the response message
try {
String postdata = URLEncoder.encode("apikey", "UTF-8") + "=" + URLEncoder.encode("abc123", "UTF-8");
postdata += "&" + URLEncoder.encode("passkey", "UTF-8") + "=" + URLEncoder.encode("321cba", "UTF-8");
postdata += "&" + URLEncoder.encode("tagg", "UTF-8") + "=" + URLEncoder.encode("sometagg", "UTF-8");
postdata += "&" + URLEncoder.encode("mobile", "UTF-8") + "=" + URLEncoder.encode("16045551234", "UTF-8");
postdata += "&" + URLEncoder.encode("message", "UTF-8") + "=" + URLEncoder.encode("This is the message I want to send to a subscribed user.", "UTF-8");
// Send data
URL url = new URL("http://tagga.com/api/send/");
URLConnection conn = url.openConnection();
conn.setDoOutput(true);
OutputStreamWriter wr = new OutputStreamWriter(conn.getOutputStream());
wr.write(postdata);
wr.flush();
// Get the response
BufferedReader rd = new BufferedReader(new InputStreamReader(conn.getInputStream()));
// handle the response here
wr.close();
rd.close();
} catch(Exception exc) {
// handle any exceptions
}
<?xml version="1.0" encoding="UTF-8"?>
<TaggaResponse version="1.0">
<TransactionID>100</TransactionID>
<ReturnCode>0</ReturnCode>
<Message>Success - API function call successful</Message>
</TaggaResponse>
<?xml version="1.0" encoding="UTF-8"?>
<TaggaResponse version="1.0">
<TransactionID>101</TransactionID>
<ReturnCode>10</ReturnCode>
<Message>Send Frequency Exceeded - You have exceeded the send frequency for this user</Message>
</TaggaResponse>
0: Success - API function call successful
1: Invalid Recipient - Not on allowed recipient list
2: Authentication Failed - apikey and passkey not valid
3: Incomplete API Call - Not all required parameters passed in
4: Invalid Mobile Number - mobile number was not in valid format
5: Message Length Invalid - Message text must be between 0 and 100 characters (140 if paid) for the latin character set, and 0 and 50 (70 if paid) for all others
6: Invalid Input - Some or all of the required parameters are invalid
7: Unknown Remote Address - This IP address is not allowed
8: Unknown tagg - Input tagg cannot be found
9: Send Limit Exceeded - You have exceeded the daily send limit
10: Send Frequency Exceeded - You have exceeded the send frequency for this user
18: No Valid Payment Found - Campaign not created or message not sent, no valid payment found