B4A Class Twitter4J

Discussion in 'Additional libraries, classes and official updates' started by somed3v3loper, Aug 22, 2014.

  1. somed3v3loper

    somed3v3loper Well-Known Member Licensed User

    Hi all ,

    Finally I got it working with B4A . The class is included with the attached example.

    I know it is not the fanciest example or class you would see but at least it is working and you are welcome to improve it (especially error handling :) I was just trying to make it work ) .
    Also I just added setStatus function but it should be very easy to add all other functions - I hope so .

    Download Twitter4J and copy JARs to Libraries folder
    You also need Threading Library
    Add your ConsumerKey and ConsumerSecret to the project : Create your own app here .

    Also if I am doing anything wrong please let me know .


    Finally I have a question : This library needs threading almost for every function at least those I tested . Is it OK to add a thread for every function or is there any other better way ?



    Update 23DEC2015 :
    New Example ‫‫Twitter4JMediaNewAuthorization.zip : Modified with pin code Authorization .


    Update : New version Twitter4JMedia.zip
    Modified Authentication as it seems that old one is not working .
    Added a method to tweet with media (Tested a .png picture ).
     

    Attached Files:

    Last edited: Dec 23, 2015
    Johan Schoeman, moster67 and Chelu like this.
  2. Chelu

    Chelu Member Licensed User

    How can I upload a image with this class?
    There isn't any method to do it.
    You could add this functionality?
     
  3. somed3v3loper

    somed3v3loper Well-Known Member Licensed User

    If I have some time I will try to add tweet with image but meanwhile if you want to add any method you can check Twitter4J library documentation .
     
  4. somed3v3loper

    somed3v3loper Well-Known Member Licensed User

    Added .

    Please check and tell us whether it is working or not .
     
    Chelu likes this.
  5. Chelu

    Chelu Member Licensed User

    Thanks !!!
    I will checkt it this night.
    I'll tell you whether it is working or not.
     
  6. Chelu

    Chelu Member Licensed User

    Perfect!!!
    I tested with a .jpg
    Wonderful!!!
     
    somed3v3loper likes this.
  7. Chelu

    Chelu Member Licensed User

    I do not know what happened, but I retested a few weeks ago and no longer seems to work at all.
    I think the problem is authentication. Now "oauth_verifier" is no longer returned under any circumstances.
    I reinstalled the app, but can not get it to work.
    I even changed the function:
    Code:
    Sub web_PageFinished (Url As String)
        
    Log ("en PageFinished, url: " & Url)
        
    If Url.Contains("oauth_verifier"Then
            
    'get access using verifier
            Dim verifie As String=Url.SubString(Url.IndexOf("oauth_verifier")+15)
            
    Log("verifier:" & verifie)
            t.GetAccessToken(verifie)
        
    else if Url.contains ("oauth_token"Then
            
    Dim verifie As String=Url.SubString(Url.IndexOf("oauth_token")+12)
            
    Log("token:" & verifie)
            t.GetAccessToken(verifie)

        
    End If

    End Sub
    But although gives no error when posting've never published anything captured and error messages is always the same: "Exception: null"
     
  8. somed3v3loper

    somed3v3loper Well-Known Member Licensed User

    Please check the new example Twitter4JMediaNewAuthorization.zip attached to first post .
     
    Chelu likes this.
  9. Chelu

    Chelu Member Licensed User

    Very nice!!!
    Thank you!!!
     
  10. techknight

    techknight Well-Known Member Licensed User

    Must be doing something wrong. Copied the twitter4J into Libraries, but the sample is complaining about not being able to find pom.xml And its not showing up in the libraries list.

    However, pom.xml is in the libraries folder!

    Please advise?
     
  11. techknight

    techknight Well-Known Member Licensed User

    Something on my end...

    But I went in, did the Authorize, and it says Sub Tweetmedia not found and crashes.

    Edit: Eventually that quit happening, and now its working. Go figure?

    anyways... I changed it from tweetmedia to just tweet, and the MediaSent function doesnt fire to re-enable the command button.

    Looking in the Twitter class, its not immediately obvious to me how to make that work with just tweet?
     
    Last edited: Feb 9, 2016
  12. somed3v3loper

    somed3v3loper Well-Known Member Licensed User

    This one has a TweetSent event for text tweet .
    Please download and check
     

    Attached Files:

    inakigarm and DonManfred like this.
  13. techknight

    techknight Well-Known Member Licensed User

    you rock ;-)
     
  14. Steven Bacchioni

    Steven Bacchioni Member Licensed User

    Hi,

    When I run your sample app, what needs to be entered into the edittext box to the left of the "Authorize" button?

    I have my Conkey and ConSecret set with my account details.
     
  15. somed3v3loper

    somed3v3loper Well-Known Member Licensed User

    Did you try ‫‫Twitter4JMediaNewAuthorization.zip ?
     
  16. karyadi

    karyadi Member Licensed User

    Hi,
    i try Twitter4JMediaNewAuthorization.zip but it cannot connect to twitter, just white blank on webview
    i already fill my Conkey and ConSecret set with my account details.
    what happen?
     
  17. karyadi

    karyadi Member Licensed User

    Hi, sorry i have try sample Twitter4JMediaNewAuthorization.zip, it must run in release not in debug and i can authorize, but the screen to fast
    so i can not see the authorize key. how i can get authorize key by automatically ?
     
  18. somed3v3loper

    somed3v3loper Well-Known Member Licensed User

    Sorry I am very busy .
    Can you please check this version ?
    It might have not-working methods

    Code:
    dim twitter as SMMTwitter4J
                   twitter.Initialize(
    "twitter",conKey,conSecret)
               
            twitter.getAuthenticationURL(conKey,conSecret)

    Events
    Code:
    Sub twitter_url(url As String)
        
    'load user login url
        web.LoadUrl(url)
    End Sub
    Code:
    Sub twitter_token(token As List)
           
    'token.get(0) is token
           'token.get(1) is token secret
    End Sub
    Sorry for a not clean wrapper .I was just writing it for myself to create a very simple B4J twitter app :D
    Not sure it will work with B4A .
     

    Attached Files:

Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice