Skip to content

Commit

Permalink
add upload media
Browse files Browse the repository at this point in the history
  • Loading branch information
Kouhei Aoyagi committed Mar 26, 2024
1 parent f5c1dfc commit 12024f0
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,35 @@ 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(())
}
```

### Twitter OAuth Web
```
cd examples/oauth-web
Expand Down

0 comments on commit 12024f0

Please sign in to comment.