Coder Social home page Coder Social logo

redouane59 / twittered Goto Github PK

View Code? Open in Web Editor NEW
231.0 11.0 64.0 9.37 MB

Twitter API client for Java developers

License: Apache License 2.0

Java 100.00%
twitter-client twitter-api java twitter-cli twitter-api-v2 twitter twitter-application twitter-app twitter-json twitter-apis

twittered's People

Contributors

apptaro avatar atpanos avatar blizniukov avatar dependabot[bot] avatar greg-m73 avatar hamen avatar hazbra avatar jackhallam avatar john-baringhaus avatar juneezee avatar lepit31 avatar marcphilippebeaujean-abertay avatar matbroughty avatar mattes3 avatar nycodeghg avatar phantomydn avatar rakambda avatar redouane59 avatar rzo1 avatar snicoll avatar stephenc avatar suomi35 avatar swisstechguy avatar takeshitakenji avatar vrael avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

twittered's Issues

Possibility to get further information of a tweet

Hi, would it be possible to extend the Tweet class to be able to get the following information:

  • The geographic location of a tweet
  • The name of the author of a tweet
  • The hashtags of a tweet
  • The mentioned URLs in a tweet
  • The media of a tweet (picture, video, GIF)

Missing LICENSE

Hi folks,
this is real good software. Is it open source? If so, could you please add an open source license so that I know how I may use this library?

Best...
Matthias

How to do a callback for Java desktop Application

Hi;

Thank you for your awesome work.
I made my Twitter client for Android using another library. I came by your twitter library from Twitter developer site. I am planning to do a desktop application that can work on both windows and mac platforms, my question is, how to do callback function so it can retrieve the access token from the web after my app been authorized by the user?
Is there is any example/documentation for doing such a thing?

Thanks.

Question: Can this client tweet?

I just discovered this java client library. Looks cool.

However, I was unable to find any information about tweeting text from this library.
Is this feature available that I am not able to see or it is not implemented yet?

Support for the new API features :-)

Hello from Twitter Developer Relations!

First of all: Thank You, for building on our API, and for supporting our developer communities! You, and many projects like this one, are among the reasons why Twitter data is much-appreciated by developers. We historically haven't built libraries and SDKs - the communities, YOU, have done so - and I'm here to tell you how much we appreciate that, and that we know you're around!

As you already know, we are currently building a brand new API platform that (over time) will replace the current one. I would love to connect with you on any plans to add support for Twitter Developer Labs to twitter-lite! We're looking to be much more focused on proper API versioning, and are basing our specification on OpenAPI.

We would really love to continue to work with you so as you continue to help the Java community. Thank you, again!

twitterClient.uploadMedia not working?

Hi, I can't upload media to Twitter using twitterClient.uploadMedia() - is there something special to consider?

After building the twitterClient with the TwitterCredentials builder() and adding the 4 secrets/keys I execute the following code:

String filename	= "twitter.png"
File mediaFile	= new File(filename)
assert mediaFile.exists() == true
UploadMediaResponse mediaResponse	= twitterClient.uploadMedia(mediaFile, MediaCategory.TWEET_IMAGE)

The resulting mediaResponse exists but has no mediaId (null) and size of 0.

Btw. reading users and tweets works.

Filtered Stream doesn't return any tweet.

Hey there,

I'm trying to use the filtered stream in v2 yet it isn't returning any tweet.

        if(twitterClient.retrieveFilteredStreamRules() != null) {
            twitterClient.deleteFilteredStreamRule("from:CharSequence");
            twitterClient.addFilteredStreamRule("from:CharSequence","from:CharSequence");
            System.out.println("Added rule");
        }

        try {
            System.out.println("Started filtered stream");

            twitterClient.retrieveFilteredStreamRules().forEach(streamRule -> {
                System.out.println(streamRule.getValue());
            });

            Future<Response> future = twitterClient.startFilteredStream(System.out::println);

            try {
                future.get(5, TimeUnit.SECONDS);
            } catch (TimeoutException exc) {
                exc.printStackTrace();
            }
        } catch (Exception exception) {
            exception.printStackTrace();
        }

It should at least return a tweet from my twitter account yet it doesn't return anything, yet the rules are set. Any idea as to why?

Streaming API and tweet Consumer.

There is a case when the Consumer is triggered on data that is not a JSON tweet but more like a notification for a limitation.

The problem occurs in RequestHelperV2.onResponse(Call call, final Response response), when trying to map the json to a TwitterV2.class, both data & includes properties will be null.

Here is the json received:

    {
      "title":"ConnectionException",
      "detail":"This stream is currently at the maximum allowed connection limit.",
      "connection_issue":"TooManyConnections",
      "type":"https://api.twitter.com/2/problems/streaming-connection"
    }

When this happens, the stream is disconnected.
You can easily reproduce the problem when starting two twitterclient instance using the same credentials and opening a stream.

I think firing some new Consumer<TwitterError> would be a good approach, and let the developper handle the error & reconnect the stream.

for example :
twitterClient.startFilteredStream(consumer, errorConsumer);

I'll try to provide a pull request based on your return. (i'm in a rush, so i don't know when).

How to launch integration tests which need twitter credentials when deploying ?

Currently when deploying only the unit tests are performed but there are no integration tests. Tests in classes like ITwitterClientV2Test are all disabled because it requieres twitter account credentials to be working fine...

How can we manage this ? Does TravisCI can host securely some credentials that we could use for integration tests ?

Example of test :

  @Test
  public void testFollowAndUnfollow() {
    User           user           = twitterClient.getUserFromUserName("red1");
    FollowResponse followResponse = twitterClient.follow(this.userId, user.getId());
    assertTrue(followResponse.getData().isFollowing());
    assertFalse(followResponse.getData().isPending_follow());
    FollowResponse unfollowResponse = twitterClient.unfollow(this.userId, user.getId());
    assertFalse(unfollowResponse.getData().isFollowing());
    assertEquals(RelationType.NONE, twitterClient.getRelationType("92073489", "66533"));
  }

Next_token parameter KO

Calling recent search 7 days endpoint with next_token parameter, the API response is always empty.

getOAuth1AccessToken NOT working !

Missing parameter assign(put) in getOAuth1AccessToken(requestToken, verifier):

parameters.put("oauth_token", requestToken.oauthToken);

Search 7 days broken

public static final String to be modified

(POST) Error calling https://api.twitter.com/2/tweets/search/recent {"errors":[{"parameters":{"tweet.fields":
["tweet.fields=attachments,author_id,created_at,entities,geo,id,in_reply_to_user_id,lang,possibly_sensitive,public_metrics,referenced_tweets,source,text,withheld,context_annotations,conversation_id,reply_settings"]}
,"message":"The `tweet.fields` query parameter value [tweet.fields=attachments] is not one of [attachments,author_id,context_annotations,conversation_id,created_at,entities,geo,id,in_reply_to_user_id,lang,non_public_metrics,organic_metrics,possibly_sensitive,promoted_metrics,public_metrics,referenced_tweets,reply_settings,source,text,withheld]"}],"title":"Invalid Request","detail":"One or more parameters to your request was invalid.","type":"https://api.twitter.com/2/problems/invalid-request"} - 400

Rename the library

Find a name more personal.

Impacts :

  • Maven central repository
  • SonarCloud
  • TravisCI
  • Local git config
  • Readme urls

User attributes: name x screen_name x username

In the version 1.0 of the user's object model, I see those fields related with the user's name:

  • name (ex. "name": "Twitter API")
  • screen_name (ex. "screen_name": "twitterapi")

Then in the version 2.0 of the user's object model, those are the attributes:

  • name (ex. "name": "Twitter Dev")
  • username (ex. "username": "TwitterDev", same as screen_name of the version 1.0).

The problem is the Java DTO has only one attribute name mapped to the JSON attributes screen_name and username, meaning the JSON attribute name is being ignored and the first ones are wrongly mapped.

My suggestion is mapping the JSON attributes screen_name and username to the Java DTO username and map the JSON attribute name to a new DTO attribute name.

Option to get additional fields in Sampled Stream api

Is it possible to add a feature to send different get parameters to the request as the samples stream provides these features ?

I see that in the class URLHelper.java , getFilteredStreamUrl() already has these fields appended.

I am using a local build currently for these fields. I can submit a pull request with these changes if it is ok.

Refer: https://developer.twitter.com/en/docs/twitter-api/tweets/sampled-stream/api-reference/get-tweets-sample-stream

full tweets object

hi,
Im trying to get a all the tweets data(media, id ...) with the all the user data (name , profile picture..)
so I wrote this code :
twitterClient.getUserFromUserName(username)
and it returns:
com.github.redouane59.twitter.dto.user.UserV2@62cfe06c

Crashing in Activity's on Android Studio

  • Works using Unit Tests and Instrumented Tests
  • Crashes when doing anything other than .setCreditials, .getCredientals, and initialization.
  • When trying to get BearerToken (same error for many other get functions):
    E/AndroidRuntime: FATAL EXCEPTION: main Process: com.teamo.myapplication, PID: 20367 java.lang.RuntimeException: Unable to start activity ComponentInfo{com.teamo.myapplication/com.teamo.myapplication.DisplayTwitterNots}: java.util.NoSuchElementException at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3762) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3938) at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:85) at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135) at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2277) at android.os.Handler.dispatchMessage(Handler.java:106) at android.os.Looper.loop(Looper.java:246) at android.app.ActivityThread.main(ActivityThread.java:8425) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:596) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1130) Caused by: java.util.NoSuchElementException at com.github.redouane59.twitter.helpers.-$$Lambda$_8WOp8kDeNBzPknjyivyeUPODww.get(Unknown Source:2) at java.util.Optional.orElseThrow(Optional.java:286) at com.github.redouane59.twitter.helpers.RequestHelperV2.getBearerToken(RequestHelperV2.java:128) at com.github.redouane59.twitter.TwitterClient.getBearerToken(TwitterClient.java:666) at com.teamo.myapplication.DisplayTwitterNots.testSearchTweets7days1(DisplayTwitterNots.java:89) at com.teamo.myapplication.DisplayTwitterNots.onCreate(DisplayTwitterNots.java:85) at android.app.Activity.performCreate(Activity.java:8183) at android.app.Activity.performCreate(Activity.java:8167) at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1309) at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3735) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3938)  at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:85)  at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135)  at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95)  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2277)  at android.os.Handler.dispatchMessage(Handler.java:106)  at android.os.Looper.loop(Looper.java:246)  at android.app.ActivityThread.main(ActivityThread.java:8425)  at java.lang.reflect.Method.invoke(Native Method)  at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:596)  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1130)  I/Process: Sending signal. PID: 20367 SIG: 9
    Link to our repository to see the full code: https://github.com/Wolfehh/TeamO/tree/twittered

getUserTimeline() doesn't show private tweets

See : #156
Regression, it was working at least until v1.12

Error is :

{"errors":[{"value":"123","parameter":"id","resource_type":"user","section":"data","title":"Authorization Error","detail":"Sorry, you are not authorized to see the user with id: [123].","type":"https://api.twitter.com/2/problems/not-authorized-for-resource"}]}

Manage twitter credentials by argument

As @hypr2771 was suggesting, we have to use an argument containing the credentials file path like :
-Dtwitter.credentials.file.path=/my/path/to/json instead of working with a fixed path in resources folder.
Without it, the external lib should not work.

Improve Search Tweets endpoints

Currently the methods like searchForTweetsWithin7days only allow to get a fix result size (100). It would be better to give the user the possibility to make several calls using a next_token got on the method turn to retrieve more tweets.

@sparack

Not closed connection issue

When calling some endpoint (i.e: getTweet) outside unit test (e.g in a main class), the connection is not closed after usage and the program never ends.
@sparack

Request to add Send Direct Message end point

Is there any plan to add direct message related end points?

Sending message events
To send a new Direct Message use POST direct_messages/events/new (message_create). Optionally, you may also attach Quick Replies or media (image, GIF or video).

How to set `media_ids` (and not `media_id`) which doesn't exist in twitter API

Hi all, I was working on a retrofit client for twitter and found your repository listed on twitter website.

It seems this is still under active development, do you know if it's ready for production use? We use spring boot 1.5.9

Edit

After a first trial, it's easy to get going with posting a tweet. However, the current TwitterClient.java is not yet implementing many methods, for example, it force you to use only one media in media_ids.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.