ttttttttumblr

more sleeping and sleeping is sleeping.
Nov 12
Permalink
API The Tumblr API is implemented over standard HTTP requests. This allows Tumblr to be integrated with just about any application that can connect to the web. /api/read Reading Tumblr data is easy: just fetch the page at http://(you).tumblr.com/api/read and you’ll get a structured XML version of your content in this format: The most recent 20 posts are included by default. You may pass these optional GET parameters: * start - The post offset to start from. The default is 0. * num - The number of posts to return. The default is 20, and the maximum is 50. * type - The type of posts to return. If unspecified or empty, all types of posts are returned. Must be one of regular, quote, photo, link, conversation, or video. For detailed example feeds, see the live Read API on Marco’s Log or the demo tumblelog. A browser that pretty-prints XML, such as Firefox, is recommended. JSON output By using /api/read/json instead of /api/read when calling the Read API, the output will be sent as JSON assigned to a Javascript variable named tumblr_api_read. All regular Read API parameters are accepted. Example: To view a human-readable map of the array’s structure for easy reference, pass debug=1 as a GET parameter. The output will be like that of PHP’s print_r() function. /api/write The Write API is a very simple HTTP interface. To create a post, send a POST request to http://www.tumblr.com/api/write with the following parameters: * email - Your account’s email address. * password - Your account’s password. * type - The post type. * (content parameters) - These vary by post type. * generator (optional) - A short description of the application making the request for tracking and statistics, such as “John’s Widget 1.0”. Must be 64 or fewer characters. Post types These are the valid values for the type parameter, with the associated content parameters that each type supports: * regular - Requires at least one: o title o body (HTML allowed) * photo - Requires either source or data, but not both. If both are specified, source is used. o source - The URL of the photo to copy. This must be a web-accessible URL, not a local file or intranet location. o data - An image file. See File uploads below. o caption (optional, HTML allowed) * quote o quote o source (optional, HTML allowed) * link o name (optional) o url o description (optional, HTML allowed) * conversation o title (optional) o conversation * video - Requires either embed or data, but not both. o embed - Either the complete HTML code to embed the video, or the URL of a YouTube video page. o data - A video file for a Vimeo upload. See File uploads below. o title (optional) - Only applies to Vimeo uploads. o caption (optional, HTML allowed) * audio o data - An audio file. See File uploads below. o caption (optional, HTML allowed) File uploads File uploads can be done in a data parameter where specified above. You may use either of the common encoding methods: * multipart/form-data method, like a file upload box in a web form. Maximum size: o 50 MB for videos o 10 MB for photos o 5 MB for audio This is recommended since there’s much less overhead. * Normal POST method, in which the file’s entire binary contents are URL-encoded like any other POST variable. Maximum size: o 5 MB for videos o 5 MB for photos o 5 MB for audio Return values We return standard HTTP status codes for each request, plus a plaintext response. * 201 Created - Success! The newly created post’s ID is returned. * 403 Forbidden - Your email address or password were incorrect. * 400 Bad Request - There was at least one error while trying to save your post. Errors are sent in plain text, one per line. Sample PHP code $tumblr_email, ‘password’ => $tumblr_password, ‘type’ => $post_type, ‘title’ => $post_title, ‘body’ => $post_body, ‘generator’ => ‘API example’ ) ); // Send the POST request (with cURL) $c = curl_init(‘http://www.tumblr.com/api/write’); curl_setopt($c, CURLOPT_POST, true); curl_setopt($c, CURLOPT_POSTFIELDS, $request_data); curl_setopt($c, CURLOPT_RETURNTRANSFER, true); $result = curl_exec($c); $status = curl_getinfo($c, CURLINFO_HTTP_CODE); curl_close($c); // Check for success if ($status == 201) { echo “Success! The new post ID is $result.\n”; } else if ($status == 403) { echo ‘Bad email or password’; } else { echo “Error: $result\n”; } ?> If you have any questions, please pass them along to Tumblr Support. Other actions We provide additional actions that may be beneficial. Pass these values as a POST parameter called action. You may omit type and other post-specific parameters since a post is not created for these actions. * authenticate - Only checks authentication without creating a post. Returns 403 if invalid, 200 if valid. * check-vimeo - Checks to see if the user is logged into Vimeo through Tumblr. This is required to upload videos. Returns a 400 status with a message and a login URL in the response if the user is not logged into Vimeo. If the user is logged in, this returns a 200 status with the maximum number of bytes available for the user to upload as the response. * check-audio - Checks to see if the user can upload an audio file. Returns a 400 status if the user has exceeded the daily audio quota, or a 200 status with “OK” as the response.
Tumblr