API DocumentationWelcome to the Twicli API. The Twicli platform is totally open to developers who may wish to integrate a photo, video and audio sharing service into their desktop and mobile applications. Please note that our API is in beta. If you wish to integrate please see the basic and advanced methods below. You may want to follow @TwicliAPI for announcements and updates. You can also contact us via this form. API KeySending an API key with your request is optional and, if sent, will help us track which apps are using the service. Benefits of using an API keyIn the next release of Twicli, your app will be advertised on Twicli with via YourApp next to posts you send. If no API key is sent then via API will be displayed instead. By providing an API key, Twicli staff will be able to track which apps are using the API. You will receive free advertising on Twicli in the top right ad placeholder. Your generated API keyl011p5egoxkv8ldq1tbwk6ffvasg Start sending this API key with your requests immediately and your app name should start to appear next to posts in the latest release of Twicli. Basic MethodsApplication developers will most likely be familiar with these methods already from using other APIs.
URLhttp://twic.li/api/uploadPhotoFunctionThis method simply uploads a photo to Twicli. The photo will instantly appear in the users photo listing. No tweet is sent. MethodPOST Data should be submitted as multipart/form-data. Requires AuthenticationTRUE Be sure to provide the username and password parameters. Parameters
Limitations & Notes
Example ResponsesXML - Success
<response status="ok">
<content type="photo"> <id>ek</id> <screen_name>sampicli</screen_name> <user_id>21186869</user_id> <url>http://twic.li/ek</url> <num_comments>2</num_comments> <num_user_tags>0</num_user_tags> <num_views>51</num_views> <latitude>39.5245</latitude> <longitude>2.46233</longitude> <show_map>1</show_map> <camera_make>Apple</camera_make> <camera_model>iPhone</camera_model> <timestamp>1251243361</timestamp> <sizes> <original_url>http://twic.li/api/photo.jpg?id=ek&size=original</original_url> <large_url>http://twic.li/api/photo.jpg?id=ek&size=large</large_url> <medium_url>http://twic.li/api/photo.jpg?id=ek&size=medium</medium_url> <small_url>http://twic.li/api/photo.jpg?id=ek&size=small</small_url> <square_url>http://twic.li/api/photo.jpg?id=ek&size=square</square_url> <tile_url>http://twic.li/api/photo.jpg?id=ek&size=tile</tile_url> <largest_available_url>http://twic.li/api/photo.jpg?id=ek&size=largest_available</largest_available_url> </sizes> </content> </response> XML - Fail
<response status="fail">
<error_code>1x07</error_code> <error_text>Invalid file type. We support JPG, GIF and PNG images</error_text> </response> Error Codes
Code SamplesPHP using cURL
<?php
// This script will upload testimage.jpg through the Twicli uploadPhoto API method. // Note: testimage.jpg must be in the same directory as this PHP script. set_time_limit(0); // Define POST variables array $postfields = array(); $postfields['username'] = 'username'; $postfields['password'] = 'password'; $postfields['show_map'] = 0; $postfields['photo'] = '@testimage.jpg'; $api_url = 'http://twic.li/api/uploadPhoto'; // Initialize cURL and set options $curl = curl_init(); curl_setopt($curl, CURLOPT_URL, $api_url); curl_setopt($curl, CURLOPT_HEADER, false); curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); curl_setopt($curl, CURLOPT_BINARYTRANSFER, 1); curl_setopt($curl, CURLOPT_POST, 3); curl_setopt($curl, CURLOPT_POSTFIELDS, $postfields); // Execute cURL and store the API's response $response = curl_exec($curl); // Display the output var_dump($response); ?>
URLhttp://twic.li/api/uploadPhotoAndTweetFunctionThis method uploads a photo to Twicli and sends a status update to Twitter. The photo will instantly appear in the users photo listing. MethodPOST Data should be submitted as multipart/form-data. Requires AuthenticationTRUE Be sure to provide the username and password parameters. Parameters
Limitations & Notes
Example ResponsesXML - Success
<response status="ok">
<content type="photo"> <id>ek</id> <screen_name>sampicli</screen_name> <user_id>21186869</user_id> <url>http://twic.li/ek</url> <num_comments>2</num_comments> <num_user_tags>0</num_user_tags> <num_views>51</num_views> <latitude>39.5245</latitude> <longitude>2.46233</longitude> <show_map>1</show_map> <camera_make>Apple</camera_make> <camera_model>iPhone</camera_model> <timestamp>1251243361</timestamp> <sizes> <original_url>http://twic.li/api/photo.jpg?id=ek&size=original</original_url> <large_url>http://twic.li/api/photo.jpg?id=ek&size=large</large_url> <medium_url>http://twic.li/api/photo.jpg?id=ek&size=medium</medium_url> <small_url>http://twic.li/api/photo.jpg?id=ek&size=small</small_url> <square_url>http://twic.li/api/photo.jpg?id=ek&size=square</square_url> <tile_url>http://twic.li/api/photo.jpg?id=ek&size=tile</tile_url> <largest_available_url>http://twic.li/api/photo.jpg?id=ek&size=largest_available</largest_available_url> </sizes> </content> </response> XML - Fail
<response status="fail">
<error_code>1x07</error_code> <error_text>Invalid file type. We support JPG, GIF and PNG images</error_text> </response> Error CodesNote: These error codes are exactly the same as the uploadPhoto method.
Code SamplesPHP using cURL
<?php
// This script will upload testimage.jpg through the Twicli uploadPhotoAndTweet API method and send a status update to Twitter. // Note: testimage.jpg must be in the same directory as this PHP script. set_time_limit(0); // Define POST variables array $postfields = array(); $postfields['username'] = 'username'; $postfields['password'] = 'password'; $postfields['tweet'] = 'Tweet text goes here'; $postfields['show_map'] = 0; $postfields['photo'] = '@testimage.jpg'; $api_url = 'http://twic.li/api/uploadPhotoAndTweet'; // Initialize cURL and set options $curl = curl_init(); curl_setopt($curl, CURLOPT_URL, $api_url); curl_setopt($curl, CURLOPT_HEADER, false); curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); curl_setopt($curl, CURLOPT_BINARYTRANSFER, 1); curl_setopt($curl, CURLOPT_POST, 3); curl_setopt($curl, CURLOPT_POSTFIELDS, $postfields); // Execute cURL and store the API's response $response = curl_exec($curl); // Display the output var_dump($response); ?>
URLhttp://twic.li/api/photo.jpgURL (With Example Parameters)http://twic.li/api/photo.jpg?id=aeA&size=mediumFunctionThis method takes an photo id and size parameter and returns a jpg image. Note: In the next release of Twicli, this API method will also provide data for users who have been tagged into this photo. MethodGET Requires AuthenticationFALSE Parameters
Limitations & Notes
Example ResponsesSuccessThis method uses a HTTP 301 Redirect to send you to the actual image file. The example below is a medium sized image.
URL used in example: http://twic.li/api/photo.jpg?id=ek&size=medium XML - Fail
<response status="fail">
<error_code>5x04</error_code> <error_text>Invalid id. Content does not exist or is not a photo</error_text> </response> Error Codes
Code SamplesXHTML
URLhttp://twic.li/api/uploadVideoFunctionThis method simply uploads a video to Twicli. The video will instantly appear in the users video listing. No tweet is sent. MethodPOST Data should be submitted as multipart/form-data. Requires AuthenticationTRUE Be sure to provide the username and password parameters. Parameters
Limitations & Notes
Example ResponsesXML - Success
<response status="ok">
<content type="photo"> <id>abd</id> <screen_name>sampicli</screen_name> <user_id>21186869</user_id> <url>http://twic.li/abd</url> <num_comments>2</num_comments> <num_views>51</num_views> <timestamp>1251243361</timestamp> <video_file_url>http://twic.li/api/video.flv?id=abd</video_file_url> <thumb_image_url>http://b.static.picli.com/vti/l/0a3bce36c539c69edd5a9cc5.jpg</thumb_image_url> /content> </response> XML - Fail
<response status="fail">
<error_code>2x06</error_code> <error_text>There was an internal error during your video upload</error_text> </response> Error Codes
Code SamplesPHP using cURL
<?php
// This script will upload testvideo.mov through the Twicli uploadVideo API method. // Note: testvideo.mov must be in the same directory as this PHP script. set_time_limit(0); // Define POST variables array $postfields = array(); $postfields['username'] = 'username'; $postfields['password'] = 'password'; $postfields['video'] = '@testvideo.mov'; $api_url = 'http://twic.li/api/uploadVideo'; // Initialize cURL and set options $curl = curl_init(); curl_setopt($curl, CURLOPT_URL, $api_url); curl_setopt($curl, CURLOPT_HEADER, false); curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); curl_setopt($curl, CURLOPT_BINARYTRANSFER, 1); curl_setopt($curl, CURLOPT_POST, 3); curl_setopt($curl, CURLOPT_POSTFIELDS, $postfields); // Execute cURL and store the API's response $response = curl_exec($curl); // Display the output var_dump($response); ?>
URLhttp://twic.li/api/uploadVideoAndTweetFunctionThis method uploads a video to Twicli and sends a status update to Twitter. The video will instantly appear in the users video listing. MethodPOST Data should be submitted as multipart/form-data. Requires AuthenticationTRUE Be sure to provide the username and password parameters. Parameters
Limitations & Notes
Example ResponsesXML - Success
<response status="ok">
<content type="video"> <id>abd</id> <screen_name>sampicli</screen_name> <user_id>21186869</user_id> <url>http://twic.li/abd</url> <num_comments>2</num_comments> <num_views>51</num_views> <timestamp>1251243361</timestamp> <video_file_url>http://twic.li/api/video.flv?id=abd</thumb_image_url> <thumb_image_url>http://b.static.picli.com/vti/l/0a3bce36c539c69edd5a9cc5.jpg</thumb_image_url> </content> </response> XML - Fail
<response status="fail">
<error_code>2x06</error_code> <error_text>There was an internal error during your video upload</error_text> </response> Error CodesNote: These error codes are exactly the same as the uploadVideo method.
Code SamplesPHP using cURL
<?php
// This script will upload testvideo.mov through the Twicli uploadVideoAndTweet API method. // Note: testvideo.mov must be in the same directory as this PHP script. set_time_limit(0); // Define POST variables array $postfields = array(); $postfields['username'] = 'username'; $postfields['password'] = 'password'; $postfields['tweet'] = 'Tweet text goes here'; $postfields['video'] = '@testvideo.mov'; $api_url = 'http://twic.li/api/uploadVideoAndTweet'; // Initialize cURL and set options $curl = curl_init(); curl_setopt($curl, CURLOPT_URL, $api_url); curl_setopt($curl, CURLOPT_HEADER, false); curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); curl_setopt($curl, CURLOPT_BINARYTRANSFER, 1); curl_setopt($curl, CURLOPT_POST, 3); curl_setopt($curl, CURLOPT_POSTFIELDS, $postfields); // Execute cURL and store the API's response $response = curl_exec($curl); // Display the output var_dump($response); ?>
URLhttp://twic.li/api/video.flvURL (With Example Parameters)http://twic.li/api/video.flv?id=abdFunctionThis method takes a video id and returns a flash video for it. MethodGET Requires AuthenticationFALSE Parameters
Limitations & Notes
Example ResponsesSuccessThis method uses a HTTP 301 Redirect to send you to the actual flash video file. Example URL: http://twic.li/api/video.flv?id=abd XML - Fail
<response status="fail">
<error_code>6x02</error_code> <error_text>Invalid ID. Content does not exist or is not a video</error_text> </response> Error Codes
URLhttp://twic.li/api/uploadAudioFunctionThis method simply uploads an audio file to Twicli. The audio will instantly appear in the users audio listing. No tweet is sent. MethodPOST Data should be submitted as multipart/form-data. Requires AuthenticationTRUE Be sure to provide the username and password parameters. Parameters
Limitations & Notes
Example ResponsesXML - Success
<response status="ok">
<content type="audio"> <id>anD</id> <screen_name>sampicli</screen_name> <user_id>21186869</user_id> <url>http://twic.li/anD</url> <num_comments>2</num_comments> <num_views>51</num_views> <timestamp>1251243361</timestamp> <audio_file_url>http://twic.li/api/audio.mp3?id=anD</audio_file_url> </content> </response> XML - Fail
<response status="fail">
<error_code>3x06</error_code> <error_text>There was an internal error during your audio upload.</error_text> </response> Error Codes
Code SamplesPHP using cURL
<?php
// This script will upload testaudio.mp3 through the Twicli uploadAudio API method. // Note: testaudio.mp3 must be in the same directory as this PHP script. set_time_limit(0); // Define POST variables array $postfields = array(); $postfields['username'] = 'username'; $postfields['password'] = 'password'; $postfields['audio'] = '@testaudio.mp3'; $api_url = 'http://twic.li/api/uploadAudio'; // Initialize cURL and set options $curl = curl_init(); curl_setopt($curl, CURLOPT_URL, $api_url); curl_setopt($curl, CURLOPT_HEADER, false); curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); curl_setopt($curl, CURLOPT_BINARYTRANSFER, 1); curl_setopt($curl, CURLOPT_POST, 3); curl_setopt($curl, CURLOPT_POSTFIELDS, $postfields); // Execute cURL and store the API's response $response = curl_exec($curl); // Display the output var_dump($response); ?>
URLhttp://twic.li/api/uploadAudioAndTweetFunctionThis method uploads an audio file to Twicli and sends a status update to Twitter. The audio will instantly appear in the users audio listing. MethodPOST Data should be submitted as multipart/form-data. Requires AuthenticationTRUE Be sure to provide the username and password parameters. Parameters
Limitations & Notes
Example ResponsesXML - Success
<response status="ok">
<content type="audio"> <id>anD</id> <screen_name>sampicli</screen_name> <user_id>21186869</user_id> <url>http://twic.li/anD</url> <num_comments>2</num_comments> <num_views>51</num_views> <timestamp>1251243361</timestamp> <audio_file_url>http://twic.li/api/audio.mp3?id=anD</audio_file_url> </content> </response> XML - Fail
<response status="fail">
<error_code>3x06</error_code> <error_text>There was an internal error during your audio upload</error_text> </response> Error CodesNote: These error codes are exactly the same as the uploadAudio method.
Code SamplesPHP using cURL
<?php
// This script will upload testimage.jpg through the Twicli uploadPhoto API method. // Note: testimage.jpg must be in the same directory as this PHP script. set_time_limit(0); // Define POST variables array $postfields = array(); $postfields['username'] = 'username'; $postfields['password'] = 'password'; $postfields['show_map'] = 0; $postfields['photo'] = '@testimage.jpg'; $api_url = 'http://twic.li/api/uploadPhoto'; // Initialize cURL and set options $curl = curl_init(); curl_setopt($curl, CURLOPT_URL, $api_url); curl_setopt($curl, CURLOPT_HEADER, false); curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); curl_setopt($curl, CURLOPT_BINARYTRANSFER, 1); curl_setopt($curl, CURLOPT_POST, 3); curl_setopt($curl, CURLOPT_POSTFIELDS, $postfields); // Execute cURL and store the API's response $response = curl_exec($curl); // Display the output var_dump($response); ?>
URLhttp://twic.li/api/audio.mp3URL (With Example Parameters)http://twic.li/api/audio.mp3?id=g6FunctionThis method takes an audio id and returns an mp3 audio file. MethodGET Requires AuthenticationFALSE Parameters
Limitations & Notes
Example ResponsesSuccessThis method uses a HTTP 301 Redirect to send you to the actual audio file. Example URL: http://twic.li/api/audio.mp3?id=g6 XML - Fail
<response status="fail">
<error_code>7x02</error_code> <error_text>Invalid ID. Content does not exist or is not audio.</error_text> </response> Error Codes
Advanced MethodsFor developers who want to try something new...
URLhttp://twic.li/api/getContentURL (With Example Parameters)http://twic.li/api/getContent?id=aeAFunctionThis method takes an id and returns information for that piece of content. Information is also provided that distinguishes between the various content types (photos, videos, audio and sets). MethodGET Requires AuthenticationFALSE Parameters
Limitations & Notes
Example ResponsesXML - Success
<response status="ok">
<content type="photo"> <id>ek</id> <screen_name>sampicli</screen_name> <user_id>21186869</user_id> <url>http://twic.li/ek</url> <num_comments>2</num_comments> <num_user_tags>0</num_user_tags> <num_views>51</num_views> <latitude>39.5245</latitude> <longitude>2.46233</longitude> <show_map>1</show_map> <camera_make>Apple</camera_make> <camera_model>iPhone</camera_model> <timestamp>1251243361</timestamp> <sizes> <original_url>http://twic.li/api/photo.jpg?id=ek&size=original<original_url> <large_url>http://twic.li/api/photo.jpg?id=ek&size=large<large_url> <medium_url>http://twic.li/api/photo.jpg?id=ek&size=medium<medium_url> <small_url>http://twic.li/api/photo.jpg?id=ek&size=small<small_url> <square_url>http://twic.li/api/photo.jpg?id=ek&size=square<square_url> <tile_url>http://twic.li/api/photo.jpg?id=ek&size=tile<tile_url> <largest_available_url>http://twic.li/api/photo.jpg?id=ek&size=largest_available<largest_available_url> </sizes> </content> </response> XML - Fail
<response status="fail">
<error_code>4x02</error_code> <error_text>Invalid id. Content does not exist.</error_text> </response> Error Codes
Code SamplesPHP using cURL
<?php
// This script will request data for an individual photo through the Twicli getContent API method. set_time_limit(0); $api_url = 'http://twic.li/api/getContent?id=aeA'; // Initialize cURL and set options $curl = curl_init(); curl_setopt($curl, CURLOPT_URL, $api_url); curl_setopt($curl, CURLOPT_HEADER, false); curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); // Execute cURL and store the API's response $response = curl_exec($curl); // Display the output var_dump($response); ?>
URLhttp://twic.li/api/getUsersContentURL (With Example Parameters)http://twic.li/api/getUsersContent?username=twiclistaff&content_type=photosFunctionThis method takes either a userid OR username parameter. This function returns a list of a particular users content depending on the content_type. Works with photos, videos and audio listings. MethodGET Requires AuthenticationFALSE Parameters
Limitations & Notes
Example ResponsesXML - Success
<response status="ok">
<content type="photo"> <id>ek</id> <screen_name>sampicli</screen_name> <user_id>21186869</user_id> <url>http://twic.li/ek</url> <num_comments>2</num_comments> <num_user_tags>0</num_user_tags> <num_views>51</num_views> <latitude>39.5245</latitude> <longitude>2.46233</longitude> <show_map>1</show_map> <camera_make>Apple</camera_make> <camera_model>iPhone</camera_model> <timestamp>1251243361</timestamp> <sizes> <original_url>http://twic.li/api/photo.jpg?id=ek&size=original<original_url> <large_url>http://twic.li/api/photo.jpg?id=ek&size=large<large_url> <medium_url>http://twic.li/api/photo.jpg?id=ek&size=medium<medium_url> <small_url>http://twic.li/api/photo.jpg?id=ek&size=small<small_url> <square_url>http://twic.li/api/photo.jpg?id=ek&size=square<square_url> <tile_url>http://twic.li/api/photo.jpg?id=ek&size=tile<tile_url> <largest_available_url>http://twic.li/api/photo.jpg?id=ek&size=largest_available<largest_available_url> </sizes> </content> <content type="photo"> ... etc ... etc </response> XML - Fail
<response status="fail">
<error_code>10x01</error_code> <error_text>Missing required GET parameters userid OR username</error_text> </response> Error Codes
URLhttp://twic.li/api/tagUserIntoPhotoFunctionThis method will tag a twitter user into a photo based on coordinates from the top left of the large size image. MethodPOST Requires AuthenticationTRUE Be sure to provide the username and password parameters. Parameters
Visual Diagram
Limitations & Notes
Example ResponsesXML - Success
<response status="ok">
<success_code>9x02</success_code> <success_text>You have tagged @sampicli into this photo</success_text> <tagged_user> <screen_name>sampicli</screen_name> <user_id>21186869</user_id> <url>http://twic.li/ek</url> <x_coord>301</x_coord> <y_coord>271</y_coord> <x_offset>85</x_offset> <y_offset>102</y_offset> <timestamp>1251243361</timestamp> </tagged_user> </response> XML - Fail
<response status="fail">
<error_code>8x09</error_code> <error_text>Invalid ID. Content does not exist or is not a photo</error_text> </response> Error Codes
Success Codes
Code SamplesPHP using cURL
<?php
// This script will tag the Twitter user 'sampicli' into a photo through the Twicli tagUserIntoPhoto API method. set_time_limit(0); // Define POST variables array $postfields = array(); $postfields['id'] = 'aus'; $postfields['username'] = 'username'; $postfields['password'] = 'password'; $postfields['tagged_username'] = 'sampicli'; $postfields['x_coord'] = 95; $postfields['y_coord'] = 105; $postfields['x_offset'] = 100; $postfields['x_offset'] = 120; $api_url = 'http://twic.li/api/tagUserIntoPhoto'; // Initialize cURL and set options $curl = curl_init(); curl_setopt($curl, CURLOPT_URL, $api_url); curl_setopt($curl, CURLOPT_HEADER, false); curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); curl_setopt($curl, CURLOPT_POST, 3); curl_setopt($curl, CURLOPT_POSTFIELDS, $postfields); // Execute cURL and store the API's response $response = curl_exec($curl); // Display the output var_dump($response); ?> Coming Soon...These methods are under development and will be released in the future.
|