#twitter #oauth

twapi

A simple Twitter library. This is easy for customize.

9 unstable releases

✓ Uses Rust 2018 edition

0.5.0 Jun 27, 2019
0.4.3 Apr 24, 2019
0.4.1 May 13, 2018
0.4.0 Mar 23, 2018
0.1.0 Mar 6, 2018

#15 in Authentication

Download history 5/week @ 2019-04-11 15/week @ 2019-04-18 19/week @ 2019-04-25 9/week @ 2019-05-02 13/week @ 2019-05-09 21/week @ 2019-05-16 33/week @ 2019-05-23 4/week @ 2019-05-30 10/week @ 2019-06-06 27/week @ 2019-06-13 53/week @ 2019-06-20 36/week @ 2019-06-27 112/week @ 2019-07-04 19/week @ 2019-07-11 9/week @ 2019-07-18

80 downloads per month

MIT/Apache

27KB
693 lines

twapi-rs

A simple Twitter library. This is easy for customize.

Documentation

Description

twapi-rs* is is a simple Twitter library. This is easy for customize.

Features

  • Application Only Authentication
  • User Authentication
  • JSON support(dm_event, welcome_message, media_metadata)
  • Oauth1.0 Authentication
  • Media Upload
  • Account Activity API
  • OAuth Web Application Example
  • Accout Activity Web Application Example
  • Any Twitter API Exucutable (maybe...)

Examples

extern crate twapi;
extern crate serde_json;

use twapi::Twapi;
fn main() {
    // Application Only Authentication Sample
    let consumer_key = "xxx";
    let consumer_secret = "xxx";
    let applicaiton_auth = twapi::ApplicationAuth::new(
        &twapi::oauth2::get_bearer_token(consumer_key, consumer_secret).unwrap()
    );
    let res = applicaiton_auth.get_search_tweets(
        &vec![("q", "新宿"), ("count", "2")]
    ).unwrap();
    println!("{:?}", res);

    // Custmize Sample. Any API Executable!
    let res: serde_json::Value = applicaiton_auth.get(
        "https://api.twitter.com/1.1/statuses/user_timeline.json",
        &vec![("screen_name", "aoyagikouhei"), ("count", "2")]
    ).unwrap().json().unwrap();
    println!("{:?}", res);

    // JSON Sample
    let user_auth = twapi::UserAuth::new(
        "xxx",
        "xxx",
        "xxx",
        "xxx"
    );
    let data = r#"{
        "event": {
            "type": "message_create",
            "message_create": {
                "target": {
                    "recipient_id": "19522946"
                },
                "message_data": {
                    "text": "予定表〜①ハンカクだ!"
                }
            }
        }
    }"#;
    let v : serde_json::Value = serde_json::from_str(data).unwrap();
    let res = user_auth.post_direct_messages_events_new(&v);
    println!("{:?}", res);

    // Media Upload
    let res = user_auth.post_media_upload_chunk("test.mp4", "video/mp4", "tweet_video", None);
    println!("{:?}", res);
}

Dependencies

~19MB
~425K SLoC