Skip to content

Commit

Permalink
modify readme
Browse files Browse the repository at this point in the history
  • Loading branch information
Kouhei Aoyagi committed Apr 3, 2024
1 parent 9df7419 commit e00fcb4
Show file tree
Hide file tree
Showing 8 changed files with 20 additions and 35 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
## Changes

### v0.14.2 (2024/04/04)
* Add check_processing for upload
* Add post-media example

### v0.14.1 (2024/04/02)
* Orverride prefix url for each APIs

Expand Down
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "twapi-v2"
version = "0.14.1"
version = "0.14.2"
authors = ["aoyagikouhei <aoyagi.kouhei@gmail.com>"]
license = "MIT"
edition = "2021"
Expand Down
37 changes: 9 additions & 28 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@ Twitter API v2 library.
- Convenience setted parameter methods
- Bearer authentication(OAuth 2.0 Authorization Code Flow with PKCE)
- OAuth1.0a authentication(OAuth 1.0a User Contex)
- Upload Media upload.twitter.com apis
- Upload Media upload.twitter.com APIs
- Optional retriable and timeout and logging
- Optional OAuth with web example
- Optional v1 to v2 parser
- Streaming example
- Supported mocks. For example, mockito.
- **Experimental** type support.
- Type support.

## Features
### default
Expand Down Expand Up @@ -110,33 +110,14 @@ async fn main() {
}
```


### Upload Media
```rust
use twapi_v2::{
oauth10a::OAuthAuthentication,
upload::{self, media_category::MediaCategory},
};

#[tokio::main]
async fn main() -> anyhow::Result<()> {
let auth = OAuthAuthentication::new(
std::env::var("CONSUMER_KEY").unwrap_or_default(),
std::env::var("CONSUMER_SECRET").unwrap_or_default(),
std::env::var("ACCESS_KEY").unwrap_or_default(),
std::env::var("ACCESS_SECRET").unwrap_or_default(),
);
let response = upload::upload_media(
&std::path::PathBuf::from("test.jpg"),
"image/jpeg",
Some(MediaCategory::TweetImage),
None,
&auth,
)
.await?;
println!("{:?}", response);
Ok(())
}
```
cd examples/post-media
CONSUMER_KEY=xxx \
CONSUMER_SECRET=xxx \
ACCESS_KEY=xxx \
ACCESS_SECRET=xxx \
cargo run
```

### Twitter OAuth Web
Expand Down
2 changes: 1 addition & 1 deletion examples/oauth-web/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion examples/post-media/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions examples/post-media/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ async fn main() -> anyhow::Result<()> {
}),
..Default::default()
};
let res = post_2_tweets::Api::new(body).execute(&auth).await?;
tracing::info!("{:?}", res);
let (response, _header) = post_2_tweets::Api::new(body).execute(&auth).await?;
tracing::info!(response =? response, "post_2_tweets");
Ok(())
}
2 changes: 1 addition & 1 deletion examples/streaming/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit e00fcb4

Please sign in to comment.