[][src]Function tweetr::ops::start_daemon::post_tweet

pub fn post_tweet<'a, W: Write>(
    tweet: &mut QueuedTweet,
    on_behalf_of: &User,
    app: &Token<'a>,
    verbose: bool,
    output: &mut W
) -> Outcome

Post the specified tweet on behalf of the specified user and application, optionally printing progress.

The tweet is updated with the data returned by the Twitter API.

Examples

let now = Local::now();
let now = now.with_timezone(now.offset());

let mut tweet = QueuedTweet {
    author: "nabijaczleweli".to_string(),
    time: now,
    content: "This tweet will be posted, no matter the cost!".to_string(),
    time_posted: None,
    id: None,
};

let result = start_daemon::post_tweet(&mut tweet, &User {
    name: "nabijaczleweli".to_string(),
    id: 0x81423,
    access_token_key: "529443-FNlJkpZCE7a4Bbd7f1k65GtgaH7SmHlReWSESD4".to_string(),
    access_token_secret: "GVQDq88qLtJ45KR6u44A6AljW31JSSippjdipQg6gPYE5".to_string(),
}, &AppTokens {
    key: "qzuqpwr101q4RtK9mDorI9ndm".to_string(),
    secret: "HW4YG3Kdcap5ovcZ5fZfBJFedKR6GQe9MtZDS9Gm34hXiirkU5".to_string(),
}.into(), false, &mut vec![]);

assert_eq!(result.exit_value(), 0);
assert!(tweet.time_posted.is_some());
assert!(tweet.id.is_some());