jpopesculian / twitter-v2-rs Goto Github PK
View Code? Open in Web Editor NEWRust bindings for Twitter API v2
Home Page: https://docs.rs/twitter-v2/latest
Rust bindings for Twitter API v2
Home Page: https://docs.rs/twitter-v2/latest
Title. The get_user_bookmarks
method on TwitterApi
only works if you have the users id, so I don't see why there can't be a method on TwitterApiWithUserCtx
for that.
Could you include or point to some existing code that uses the PaginableApiResult to fetch a list, such as a user’s list of followers?
My first several attempts to write this worked, but are super ugly. I feel like I am missing an obvious way to write it that would be readable or even beautiful. I used the governor crate to rate–limit the requests, but I haven’t yet done anything to retry transient errors; I feel like it’s ugly enough already.
Hello there, I noticed that the in_reply_to_tweet_id
method of the TweetBuilder
struct accepts a user_id
parameter rather than a tweet_id
as the name of the method would suggest. Is this intentional, or does it actually accept a user_id
meaning that the method could be renamed to in_reply_to_user_id
?
In the example on the readme it contains the line
let auth: Oauth2Token = serde_json::from_str(&stored_oauth2_token)?;
The variable for the json string was not in the example, so I looked at the Oauth2Token struct. However, I could not find out how to find the expires
and scopes
part of the token on the Twitter developer portal.
#[derive(Clone, Debug, Serialize, Deserialize)]
pub struct Oauth2Token {
access_token: AccessToken,
refresh_token: Option<RefreshToken>,
#[serde(with = "time::serde::rfc3339")]
expires: OffsetDateTime,
scopes: Vec<Scope>,
}
On the twitter developer portal I can only figure out how to create the access token and refresh token. I am not too familiar with the twitter api but I feel like it may be possible to put expires
and scopes
inside of an Option. The Oauth2Token struct should probably have the documentation for where you can find expires
and scopes
as well as a new()
function for creating the token without deserializing from json.
I'm free to work on this issue this week, depending on which route you choose (documentation for finding expires
and scopes
or stuffing them in Options)
I’m surprised to discover this, because usually finalizing a builder consumes the builder and returns a wholly new object. As currently written, the builder cannot be a temporary; it has to be kept around as long as the request and response are so that they can refer to it.
Was this a deliberate choice? If so, can you document the reasoning for it? If not, can we change the send
(and stream
) methods to take Self
instead?
In public data structures, could we use primitive types for identifiers instead of NumericId
and StringId
?
NumericId
isn't semantic anyway like TweetId
or UserId
. I did see TweetId
/UserId
structs being generated by macros for use in request bodies, so maybe NumericId
and StringId
is useful behind the scenes. For the public API though, they make the IDs in common data types like Tweet
and User
less ergonomic to consume.
All fields on the Expansions
struct are currently private. This makes it quite useless right now and makes it impossible to retrieve things like image URLs and usernames from the tweet API. They should be made public.
Twitter puts some information about your account’s rate limits in the response headers of every request. Most important is the time at which your rate limit is reset after a 429 response. See the documentation at https://developer.twitter.com/en/docs/twitter-api/rate-limits for all of the details.
I would like there to be some way to access this information, so that I can act on it. As a quick test, I tried sticking it on to the ApiError
struct:
ApiError { title: "Too Many Requests", kind: "about:blank", status: 429, detail: "Too Many Requests", errors: [], reset: Some(1660051376) }
I added the simplest possible thing to api_error_for_status
in api_result.rs
:
let reset = self.headers().get("x-rate-limit-reset")
.map(|v| v.to_str().unwrap().parse().unwrap());
and then added the resulting value to the ApiError
that it creates.
This works, but it is not very elegant. It leaves two of the headers unavailable, and it would be rather nicer if it created a std::time::Duration
for me, though that might be going a bit far. It also doesn’t do anything to make this information available on successful requests.
Do you prefer any particular way of implementing this?
To tweet with an image, we need to follow these steps I think.
I do not know how to do step 1 - 2.
Thanks for your help.
This is probably because of the custom deserializer on duration
but I can't figure why it's behaving that way.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.