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
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:
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
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) { // ... } }});//## Create a text postAOMTblrText *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) {}];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
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) { // ... } } });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) {}];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
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) { // ... } } });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) {}];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
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) { // ... } } });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) {}];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
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) { // ... } } });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) {}];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
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) { // ... } } });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) {}];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
tblrText.deleteAsync(new AOMEmptyCallback() { @Override public void isDone(ApiomatRequestException exception) { if (exception != null) { // ... } } });[tblrText deleteAsyncWithBlock:^(NSError *error) {}]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.