So I’m trying to code an AIR widget for Tumblr. Before I actually start working on the widget, I wanted to play around with AS3 and the Tumblr API to do simple things, like reading and writing posts, editing posts etc. I got reading posts working, but when it comes to creating posts I run into an unknown brickwall.
Here’s the instructions from Tumblr’s API doc on making a POST request:
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.
These are the valid values for the type parameter, with the associated content parameters that each type supports:
regular - Requires at least one:
title
body (HTML allowed)
And here’s my AS3 code:
import flash.net.*
gogo.buttonMode = true; // gogo is the instance name of a MC on the stage
gogo.addEventListener(MouseEvent.MOUSE_DOWN, go);
function go(e:MouseEvent):void{
var variables:URLVariables = new URLVariables();
variables.email = "myemail@gmail.com";
variables.password = "mypassword";
variables.type = "regular"; // this is the post type
variables.body = "body"; // this is the body of the post
variables.group = "airtest.tumblr.com"; // this is my secondary blog that i want to post to //
var request:URLRequest = new URLRequest("http://www.tumblr.com/api/write");
request.method = URLRequestMethod.POST;
request.data = variables;
}
And for the life of me, no matter how simple I make this code, I cannot get it to work.
What am I doing wrong?