Package apis.tumblr
Class Tumblr
- java.lang.Object
-
- apis.SocialMedia
-
- apis.tumblr.Tumblr
-
public class Tumblr extends SocialMedia
Tumblr Social Media to upload PNG and MP3. search posts with keyword
-
-
Field Summary
-
Fields inherited from class apis.SocialMedia
DEFAULT_INTERVALL
-
-
Constructor Summary
Constructors Constructor Description Tumblr()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
changeSchedulerPeriod(java.lang.Integer interval)
void
getAccessTokenAndSecret(java.lang.String verifier)
traded verifier and requestToken for accessToken and AccessTokenSecretjava.util.List<java.lang.String>
getAllSubscribedKeywords()
returns all subscribed keywordsjava.lang.String
getApiName()
returns API namejava.lang.String
getAuthorizationURL()
gets Authorization URL for USer to log in to Tumblrjava.util.List<byte[]>
getRecentMediaForKeyword(java.lang.String keyword)
Get Medias posted under keywordToken
getToken()
get the oAuth 1 Tokenvoid
login()
OAuth 1 Authorization workflow to get Request Token, authorize the Application and receive Authorization URL, after authorization verifier has to be set to obtain Token containing accessToken and accessTokenSecretvoid
loginNewUser()
set accessToken and TokenSecret to null to log in new user afterwardsjava.lang.Long
postAudio(byte[] media, java.lang.String keyword)
Posts Audio File to Tumblrjava.lang.Long
postPhoto(byte[] media, java.lang.String keyword)
creates Photo Post on Tumblrboolean
postToSocialNetwork(byte[] media, MediaType mediaType, java.lang.String keyword)
posts a given byte[] containing some media to Tumblr with a keyword starts login process if no token availableboolean
postToSocialNetwork(byte[] media, MediaType mediaType, java.lang.String keyword, Token token)
posts media to Tumblr if a token already exists to skip Authorization workflowvoid
printPostURLs()
prints all saved Post URLsstatic void
setApiKey(java.lang.String key)
sets Application Consumer key which is needed to access Tumblr APIstatic void
setApiSecret(java.lang.String secret)
sets Application Secret which is needed to access Tumblr APIvoid
setBlogname(java.lang.String blogname)
set blognamevoid
setToken(Token token)
set O Auth 1 Token to access Tumblr APIvoid
startSearch()
void
stopSearch()
boolean
subscribeToKeyword(java.lang.String keyword)
search for keyword in tumblrpostsboolean
unsubscribeKeyword(java.lang.String keyword)
-
Methods inherited from class apis.SocialMedia
addAsListener, removeAsListener, updateListeners
-
-
-
-
Method Detail
-
login
public void login() throws java.lang.InterruptedException, java.util.concurrent.ExecutionException, java.io.IOException
OAuth 1 Authorization workflow to get Request Token, authorize the Application and receive Authorization URL, after authorization verifier has to be set to obtain Token containing accessToken and accessTokenSecret- Throws:
java.lang.InterruptedException
java.util.concurrent.ExecutionException
java.io.IOException
-
getAuthorizationURL
public java.lang.String getAuthorizationURL() throws java.lang.InterruptedException, java.util.concurrent.ExecutionException, java.io.IOException
gets Authorization URL for USer to log in to Tumblr- Returns:
- Authorization URL
- Throws:
java.lang.InterruptedException
java.util.concurrent.ExecutionException
java.io.IOException
-
getAccessTokenAndSecret
public void getAccessTokenAndSecret(java.lang.String verifier) throws java.lang.InterruptedException, java.util.concurrent.ExecutionException, java.io.IOException
traded verifier and requestToken for accessToken and AccessTokenSecret- Parameters:
verifier
-- Throws:
java.lang.InterruptedException
java.util.concurrent.ExecutionException
java.io.IOException
-
loginNewUser
public void loginNewUser()
set accessToken and TokenSecret to null to log in new user afterwards
-
getToken
public Token getToken()
get the oAuth 1 Token- Specified by:
getToken
in classSocialMedia
- Returns:
- Token object containing accessToken and TokenSecret
-
setToken
public void setToken(Token token)
set O Auth 1 Token to access Tumblr API- Specified by:
setToken
in classSocialMedia
- Parameters:
token
- containing accessToken and TokenSecret
-
setApiKey
public static void setApiKey(java.lang.String key)
sets Application Consumer key which is needed to access Tumblr API- Parameters:
key
-
-
setApiSecret
public static void setApiSecret(java.lang.String secret)
sets Application Secret which is needed to access Tumblr API- Parameters:
secret
-
-
postToSocialNetwork
public boolean postToSocialNetwork(byte[] media, MediaType mediaType, java.lang.String keyword)
posts a given byte[] containing some media to Tumblr with a keyword starts login process if no token available- Specified by:
postToSocialNetwork
in classSocialMedia
- Parameters:
media
- data to uploadmediaType
- i.e. PNG, MP3, gifkeyword
- keyword to search this post by- Returns:
-
postToSocialNetwork
public boolean postToSocialNetwork(byte[] media, MediaType mediaType, java.lang.String keyword, Token token)
posts media to Tumblr if a token already exists to skip Authorization workflow- Specified by:
postToSocialNetwork
in classSocialMedia
- Parameters:
media
- data to uploadmediaType
-keyword
- keyword to search this post bytoken
-- Returns:
-
subscribeToKeyword
public boolean subscribeToKeyword(java.lang.String keyword)
search for keyword in tumblrposts- Specified by:
subscribeToKeyword
in classSocialMedia
- Parameters:
keyword
- keyword to subscribe to- Returns:
- list of short URL, only last 20 entries from which comments and medias which are not PNG and MP3 are filtered out
-
printPostURLs
public void printPostURLs()
prints all saved Post URLs
-
unsubscribeKeyword
public boolean unsubscribeKeyword(java.lang.String keyword)
- Specified by:
unsubscribeKeyword
in classSocialMedia
-
changeSchedulerPeriod
public void changeSchedulerPeriod(java.lang.Integer interval)
- Specified by:
changeSchedulerPeriod
in classSocialMedia
-
startSearch
public void startSearch()
- Specified by:
startSearch
in classSocialMedia
-
getRecentMediaForKeyword
public java.util.List<byte[]> getRecentMediaForKeyword(java.lang.String keyword)
Description copied from class:SocialMedia
Get Medias posted under keyword- Specified by:
getRecentMediaForKeyword
in classSocialMedia
- Parameters:
keyword
- hashtag- Returns:
- true if successful
-
stopSearch
public void stopSearch()
- Specified by:
stopSearch
in classSocialMedia
-
getApiName
public java.lang.String getApiName()
returns API name- Specified by:
getApiName
in classSocialMedia
- Returns:
-
getAllSubscribedKeywords
public java.util.List<java.lang.String> getAllSubscribedKeywords()
returns all subscribed keywords- Specified by:
getAllSubscribedKeywords
in classSocialMedia
- Returns:
-
setBlogname
public void setBlogname(java.lang.String blogname)
set blogname- Specified by:
setBlogname
in classSocialMedia
- Parameters:
blogname
-
-
postAudio
public java.lang.Long postAudio(byte[] media, java.lang.String keyword)
Posts Audio File to Tumblr- Parameters:
media
- to postkeyword
-- Returns:
- Post id if upload was successfull
-
postPhoto
public java.lang.Long postPhoto(byte[] media, java.lang.String keyword)
creates Photo Post on Tumblr- Parameters:
media
- to postkeyword
-- Returns:
- post id if upload was successfull
-
-