Package apis.tumblr

Class Tumblr


  • public class Tumblr
    extends SocialMedia
    Tumblr Social Media to upload PNG and MP3. search posts with keyword
    • 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 AccessTokenSecret
      java.util.List<java.lang.String> getAllSubscribedKeywords()
      returns all subscribed keywords
      java.lang.String getApiName()
      returns API name
      java.lang.String getAuthorizationURL()
      gets Authorization URL for USer to log in to Tumblr
      java.util.List<byte[]> getRecentMediaForKeyword​(java.lang.String keyword)
      Get Medias posted under keyword
      Token getToken()
      get the oAuth 1 Token
      void 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 accessTokenSecret
      void loginNewUser()
      set accessToken and TokenSecret to null to log in new user afterwards
      java.lang.Long postAudio​(byte[] media, java.lang.String keyword)
      Posts Audio File to Tumblr
      java.lang.Long postPhoto​(byte[] media, java.lang.String keyword)
      creates Photo Post on Tumblr
      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
      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
      void printPostURLs()
      prints all saved Post URLs
      static void setApiKey​(java.lang.String key)
      sets Application Consumer key which is needed to access Tumblr API
      static void setApiSecret​(java.lang.String secret)
      sets Application Secret which is needed to access Tumblr API
      void setBlogname​(java.lang.String blogname)
      set blogname
      void setToken​(Token token)
      set O Auth 1 Token to access Tumblr API
      void startSearch()  
      void stopSearch()  
      boolean subscribeToKeyword​(java.lang.String keyword)
      search for keyword in tumblrposts
      boolean unsubscribeKeyword​(java.lang.String keyword)  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • Tumblr

        public Tumblr()
    • 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 class SocialMedia
        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 class SocialMedia
        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 class SocialMedia
        Parameters:
        media - data to upload
        mediaType - i.e. PNG, MP3, gif
        keyword - 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 class SocialMedia
        Parameters:
        media - data to upload
        mediaType -
        keyword - keyword to search this post by
        token -
        Returns:
      • subscribeToKeyword

        public boolean subscribeToKeyword​(java.lang.String keyword)
        search for keyword in tumblrposts
        Specified by:
        subscribeToKeyword in class SocialMedia
        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
      • 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 class SocialMedia
        Parameters:
        keyword - hashtag
        Returns:
        true if successful
      • getApiName

        public java.lang.String getApiName()
        returns API name
        Specified by:
        getApiName in class SocialMedia
        Returns:
      • getAllSubscribedKeywords

        public java.util.List<java.lang.String> getAllSubscribedKeywords()
        returns all subscribed keywords
        Specified by:
        getAllSubscribedKeywords in class SocialMedia
        Returns:
      • setBlogname

        public void setBlogname​(java.lang.String blogname)
        set blogname
        Specified by:
        setBlogname in class SocialMedia
        Parameters:
        blogname -
      • postAudio

        public java.lang.Long postAudio​(byte[] media,
                                        java.lang.String keyword)
        Posts Audio File to Tumblr
        Parameters:
        media - to post
        keyword -
        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 post
        keyword -
        Returns:
        post id if upload was successfull