Coder Social home page Coder Social logo

twitter-v2-rs's People

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

Watchers

 avatar  avatar  avatar  avatar

twitter-v2-rs's Issues

example of using PaginableApiResult?

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.

v0.1.7 release not in Github repo

Hi,

I had a question about v0.1.7 on crates.io as I don't see the v0.1.7 tag on Github.
Does it need to be pushed to the repo? I wanted to check before using the latest version.

Thanks,
Patrick

Example for Oauth2Token confusing

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)

request builder `send` methods use `&self` argument

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?

Use primitives instead of NumericId and StringId newtypes

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.

Fields on `Expansions` aren't accessible

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.

how best can we make the rate limiting information that twitter puts into the response headers available to the user?

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?

How do I tweet with an image?

To tweet with an image, we need to follow these steps I think.

  1. upload the image as media
  2. get the uploaded media id
  3. call the TwitterApi::~~~~.post_tweet().add_media(my_media_id).send()

I do not know how to do step 1 - 2.

Thanks for your help.

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.