. . .

Tumblr Module

Using the Tumblr module you can let your applications users connect themselves with Tumblr. OAuth attributes are stored on the user model. Additionally, you can create several tumblr posts.

For example:

  • text post

  • audio post

  • link post

  • photo post

  • quote post

  • video post

images/download/attachments/27164694/db3-module-tumblr.PNG

Configuration

Consumer key

Consumer key of the Tumblr app which you want to use to authenticate against.

Consumer secret

Consumer secret of the Tumblr app which you want to use to authenticate against.

More can be found in the tumblr docs.

Usage

After setting the configuration parameters, you may call the following URL in your app to start authentication for a user:

https://apiomat.org/yambas/rest/modules/Tumblr/spec/YOURAPPNAME/auth?userId=USERID&usedSystem=SYSTEM

You have to replace YOURAPPNAME with the name of your app, the USERID with the ID of your current User and SYSTEM with the system information. To fetch the UserID you can use this:

Android
int start = user.getHref().lastIndexOf("/");
String USERID = user.getHref().substring(start + 1);

You can easily access the system information by calling the attribute “system” from the class “User”.

The user is presented the Tumblr site asking him if the requesting app (with the ID set in the configuration) may be used to authenticate him. If the user clicks”OK” the authentication starts, otherwise it is cancelled.

If authentication was successful, the user object will have additional attributes set on the users object on server side. These attributes are automatically used for authentication.

Create a text post

Android
TblrText tblrText = new TblrText();
tblrText.setBlogName("yourblogname.tumblr.com");
tblrText.setContent("my tumblr post from apiomat");
tblrText.setTitle("Title of post");
tblrText.setSlug("#apiomat");
List<String> tags = new ArrayList<String>( );
tags.add( "baas" );
tblrText.setTags( tags );
tblrText.saveAsync(new AOMEmptyCallback() {
@Override
public void isDone(ApiomatRequestException exception) {
if (exception != null) {
// ...
}
}
});
iOS
//## Create a text post
AOMTblrText *tblrText = [[AOMTblrText alloc] init];
[tblrText setBlogName:@"yourblogname.tumblr.com"];
[tblrText setContent:@"my tumblr post from apiomat"];
[tblrText setTitle:@"Title of post"];
[tblrText setSlug:@"#apiomat"];
NSMutableArray *tags = [NSMutableArray arrayWithObject:@"baas"];
[tblrText setTags:tags];
[tblrText saveAsyncWithBlock:^(NSError *error) {
}];
JavaScript
var tblrText= new Apiomat.TblrText();
tblrText.setBlogName("yourblogname.tumblr.com");
tblrText.setContent("my tumblr post from apiomat");
tblrText.setTitle("Title of post");
tblrText.setSlug("#apiomat");
var tags = {"baas"};
 
tblrText.setTags( tags );
var saveCB = {
onOk : function() {
console.log("saved");
},
onError : function(error) {
console.log("Some error occured: (" + error.statusCode + ")" + error.message);
}
};
tblrText.save(saveCB);

Create audio post

Android
TblrAudio tblrAudio = new TblrAudio();
tblrAudio.setBlogName("yourblogname.tumblr.com");
tblrAudio.setCaption("post audio using apiomat");
tblrAudio.setExternalUrl("http://linktowebsite.com/audio.mp3");
tblrAudio.setSlug("#apiomat");
List<String> tags = new ArrayList<String>();
tags.add("baas");
tblrAudio.setTags(tags);
tblrAudio.saveAsync(new AOMEmptyCallback() {
@Override
public void isDone(ApiomatRequestException exception) {
if (exception != null) {
// ...
}
}
});
iOS
AOMTblrAudio *tblrAudio= [[AOMTblrAudio alloc] init];
[tblrAudio setBlogName:@"yourblogname.tumblr.com"];
[tblrAudio setCaption:@"post audio using apiomat"];
[tblrAudio setExternalUrl:@"http://linktowebsite.com/audio.mp3"];
[tblrAudio setSlug:@"#apiomat"];
NSMutableArray *tags = [NSMutableArray arrayWithObject:@"baas"];
[tblrAudio setTags:tags];
[tblrAudio saveAsyncWithBlock:^(NSError *error) {
}];
JavaScript
var tblrAudio= new Apiomat.TblrAudio();
tblrAudio.setBlogName("yourblogname.tumblr.com");
tblrAudio.setCaption("post audio using apiomat");
tblrAudio.setExternalUrl("http://linktowebsite.com/audio.mp3");
tblrAudio.setSlug("#apiomat");
var tags = {"baas"};
 
tblrAudio.setTags(tags);
var saveCB = {
onOk : function() {
onsole.log("saved");
},
onError : function(error) {
console.log("Some error occured: (" + error.statusCode + ")" + error.message);
}
};
tblrAudio.save(saveCB);

Create link post

Android
TblrLink tblrLink = new TblrLink();
tblrLink.setBlogName("yourblogname.tumblr.com");
tblrLink.setUrl("linktourl.com");
tblrLink.setTitle("Title of post");
tblrLink.setSlug("#apiomat");
List<String> tags = new ArrayList<String>();
tags.add("baas");
tblrLink.setTags(tags);
tblrLink.saveAsync(new AOMEmptyCallback() {
@Override
public void isDone(ApiomatRequestException exception) {
if (exception != null) {
// ...
}
}
});
iOS
AOMTblrLink *tblrLink=[[AOMTblrLink alloc] init];
[tblrLink setBlogName:@"yourblogname.tumblr.com"];
[tblrLink setUrl:@"linktourl.com"];
[tblrLink setTitle:@"Title of post"];
[tblrLink setSlug:@"#apiomat"];
NSMutableArray *tags = [NSMutableArray arrayWithObject:@"baas"];
[tblrLink setTags:tags];
[tblrLink saveAsyncWithBlock:^(NSError *error) {
}];
JavaScript
var tblrLink = new Apiomat.TblrLink();
tblrLink.setBlogName("yourblogname.tumblr.com");
tblrLink.setUrl("linktourl.com");
tblrLink.setTitle("Title of post");
tblrLink.setSlug("#apiomat");
var tags = {"baas"};
 
tblrLink.setTags(tags);
var saveCB = {
onOk : function() {
console.log("saved");
},
onError : function(error) {
console.log("Some error occured: (" + error.statusCode + ")" + error.message);
}
};
tblrLink.save(saveCB);

Create photo post

Android
TblrPhoto tblrPhoto = new TblrPhoto();
tblrPhoto.setBlogName("yourblogname.tumblr.com");
tblrPhoto.setUrl("http://linktowebsite.com/photo.png");
tblrPhoto.setCaption("post photo using apiomat");
tblrPhoto.setSlug("#apiomat");
List<String> tags = new ArrayList<String>();
tags.add("baas");
tblrPhoto.setTags(tags);
tblrPhoto.saveAsync(new AOMEmptyCallback() {
@Override
public void isDone(ApiomatRequestException exception) {
if (exception != null) {
// ...
}
}
});
iOS
AOMTblrPhoto *tblrPhoto=[[AOMTblrPhoto alloc] init];
[tblrPhoto setBlogName:@"yourblogname.tumblr.com"];
[tblrPhoto setUrl:@"http://linktowebsite.com/photo.png"];
[tblrPhoto setCaption:@"post photo using apiomat"];
[tblrPhoto setSlug:@"#apiomat"];
NSMutableArray *tags = [NSMutableArray arrayWithObject:@"baas"];
[tblrPhoto setTags:tags];
[tblrPhoto saveAsyncWithBlock:^(NSError *error) {
}];
JavaScript
var tblrPhoto = new Apiomat.TblrPhoto();
tblrPhoto.setBlogName("yourblogname.tumblr.com");
tblrPhoto.setUrl("http://linktowebsite.com/photo.png");
tblrPhoto.setCaption("post photo using apiomat");
tblrPhoto.setSlug("#apiomat");
var tags = {"baas"};
 
tblrPhoto.setTags(tags);
var saveCB = {
onOk : function() {
console.log("saved");
},
onError : function(error) {
console.log("Some error occured: (" + error.statusCode + ")" + error.message);
}
};
tblrPhoto.save(saveCB);

Create quote post

Android
TblrQuote tblrQuote = new TblrQuote();
tblrQuote.setBlogName("yourblogname.tumblr.com");
tblrQuote.setSource("http://linktoquote.com");
tblrQuote.setQuote("Your complete App Backend in 5 steps");
tblrQuote.setSlug("#apiomat");
List<String> tags = new ArrayList<String>();
tags.add("baas");
tblrQuote.setTags(tags);
tblrQuote.saveAsync(new AOMEmptyCallback() {
@Override
public void isDone(ApiomatRequestException exception) {
if (exception != null) {
// ...
}
}
});
iOS
TblrQuote *tblrQuote=[[TblrQuote alloc] init];
[tblrQuote setBlogName:@"yourblogname.tumblr.com"];
[tblrQuote setSource:@"http://linktoquote.com"];
[tblrQuote setQuote:@"Your complete App Backend in 5 steps"];
[tblrQuote setSlug:@"#apiomat"];
NSMutableArray *tags = [NSMutableArray arrayWithObject:@"baas"];
[tblrQuote setTags:tags];
[tblrQuote saveAsyncWithBlock:^(NSError *error) {
}];
JavaScript
var tblrQuote = new Apiomat.TblrQuote();
tblrQuote.setBlogName("yourblogname.tumblr.com");
tblrQuote.setSource("http://linktoquote.com");
tblrQuote.setQuote("Your complete App Backend in 5 steps");
tblrQuote.setSlug("#apiomat");
var tags = {"baas"};
 
tblrQuote.setTags(tags);
var saveCB = {
onOk : function() {
console.log("saved");
},
onError : function(error) {
console.log("Some error occured: (" + error.statusCode + ")" + error.message);
}
};
tblrQuote.save(saveCB);

Create video post

Android
TblrVideo tblrVideo = new TblrVideo();
tblrVideo.setBlogName("yourblogname.tumblr.com");
tblrVideo.setCaption("post video using apiomat");
tblrVideo.setEmbedCode("<iframe width=\"560\" height=\"315\" src=\"//www.linktoyoutubevideo.com\" frameborder=\"0\" allowfullscreen></iframe>");
tblrVideo.setSlug("#apiomat");
List<String> tags = new ArrayList<String>();
tags.add("baas");
tblrVideo.setTags(tags);
tblrVideo.saveAsync(new AOMEmptyCallback() {
@Override
public void isDone(ApiomatRequestException exception) {
if (exception != null) {
// ...
}
}
});
iOS
TblrVideo *tblrVideo=[[TblrVideo alloc] init];
[tblrVideo setBlogName:@"yourblogname.tumblr.com"];
[tblrVideo setCaption:@"post video using apiomat"];
[tblrVideo setEmbedCode:@""];
[tblrVideo setSlug:@"#apiomat"];
NSMutableArray *tags = [NSMutableArray arrayWithObject:@"baas"];
[tblrVideo setTags:tags];
[tblrVideo saveAsyncWithBlock:^(NSError *error) {
}];
JavaScript
var tblrVideo = new Apiomat.TblrVideo();
tblrVideo.setBlogName("yourblogname.tumblr.com");
tblrVideo.setCaption("post video using apiomat");
tblrVideo.setEmbedCode("<iframe src="\"//www.linktoyoutubevideo.com\"" allowfullscreen="" frameborder="\"0\"" height="\"315\"" width="\"560\""></iframe>");
tblrVideo.setSlug("#apiomat");
var tags = {"baas"};
 
tblrVideo.setTags(tags);
var saveCB = {
onOk : function() {
console.log("saved");
},
onError : function(error) {
console.log("Some error occured: (" + error.statusCode + ")" + error.message);
}
};
tblrVideo.save(saveCB);

Delete post

Android
tblrText.deleteAsync(new AOMEmptyCallback() {
@Override
public void isDone(ApiomatRequestException exception) {
if (exception != null) {
// ...
}
}
});
iOS
[tblrText deleteAsyncWithBlock:^(NSError *error) {
}]
JavaScript
var deleteCB = {
onOk : function() {
console.log("deleted");
},
onError : function(error) {
console.log("Some error occured: (" + error.statusCode + ")" + error.message);
}
};
tblrText.deleteModel(deleteCB);

In this excerpt “tblrText” is representative. For the other types of “post” it works similarly.

* link only available in Enterprise Documentation