Copyright 2008 Tagga Media Inc All rights Reserved
Developers may want to dynamically create taggs without visiting tagga.com. This feature is particularly useful for applications containing groups of users who would benefit from newsletter taggs.
POST URL:
http://tagga.com/api/create/
POST Parameters:
Restrictions:
Response:
An XML response is returned and details a unique transaction ID, response code, response message and the tagg variable (if successful). You are responsible for checking the response message and acting appropriately.
$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
'title' => 'Sample Tagg Title', // New tagg title
'message' => 'This is the text message for my newly created tagg.',
'url' => 'http://www.tagga.com', // URL appears on tagg web pages.
'paid' => 'TRUE', // Paid taggs get 40 extra characters and are ad free.
'daily_budget' => '100', // Set daily budget for paid taggs.
'detailed_info ' => 'So much detail and additional information.',
'image_url_1' => 'http://www.tagga.com/img/image-1.jpg',
'newsletter' => 'TRUE' // Updates are sent to all subscribers.
)
);
$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/create/',
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
title = u'Sample Tagg Title' # New tagg title
message = u'This is the text message for my newly created tagg.'
url = u'http://www.tagga.com' # URL appears on tagg web pages.
paid = u'TRUE' # Paid taggs get 40 extra characters and are ad free.
daily_budget = u'100' # Set daily budget for paid taggs.
detailed_info = u'So much detail and additional information.',
image_url_1 = u'http://www.tagga.com/img/image-1.jpg',
newsletter = u'TRUE' # Updates are sent to all subscribers.
postdata = urllib.urlencode({'apikey': apikey, 'passkey': passkey, 'tagg': tagg, 'title': title, 'message': message, 'url': url, 'paid': paid, 'daily_budget': daily_budget, 'detailed_info': detailed_info, 'image_url_1': image_url_1, 'newsletter': newsletter})
response = urllib.urlopen('http://tagga.com/api/create/', 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("title", "UTF-8") + "=" + URLEncoder.encode("Sample Tagg Title", "UTF-8");
postdata += "&" + URLEncoder.encode("message", "UTF-8") + "=" + URLEncoder.encode("This is the text message for my newly created tagg.", "UTF-8");
postdata += "&" + URLEncoder.encode("url", "UTF-8") + "=" + URLEncoder.encode("http://www.tagga.com", "UTF-8");
postdata += "&" + URLEncoder.encode("paid", "UTF-8") + "=" + URLEncoder.encode("TRUE", "UTF-8");
postdata += "&" + URLEncoder.encode("daily_budget", "UTF-8") + "=" + URLEncoder.encode("100", "UTF-8");
postdata += "&" + URLEncoder.encode("detailed_info", "UTF-8") + "=" + URLEncoder.encode("So much detail and additional information.", "UTF-8");
postdata += "&" + URLEncoder.encode("image_url_1", "UTF-8") + "=" + URLEncoder.encode("http://www.tagga.com/img/image-1.jpg", "UTF-8");
postdata += "&" + URLEncoder.encode("newsletter", "UTF-8") + "=" + URLEncoder.encode("TRUE", "UTF-8");
// Send data
URL url = new URL("http://tagga.com/api/create/");
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>
<Tagg>sometagg</Tagg>
</TaggaResponse>
<?xml version="1.0" encoding="UTF-8"?>
<TaggaResponse version="1.0">
<TransactionID>101</TransactionID>
<ReturnCode>6</ReturnCode>
<Message> Invalid Input - Some or all of the required parameters are invalid</Message>
</TaggaResponse>
0: Success - API function call successful
2: Authentication Failed - apikey and passkey not valid
3: Incomplete API Call - Not all required parameters passed in
5: Message Length Invalid - Message text must be between 0 and 100 characters for the latin character set, and 0 and 50 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
11: Title too long - Title text must be between 0 and 100 characters
16: Tagg Unavailable - The requested tagg is already in use
17: Create Frequency Exceeded - You have exceeded the create frequency for this account
18: No Valid Payment Found - Campaign not created or message not sent, no valid payment found