-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathmain.c
53 lines (42 loc) · 1.62 KB
/
main.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#include <stdio.h>
#include "twitter_api.h"
int main(int argc, char *argv[]) {
int access_token_load_error = OAuthAccessToken_load_from_file();
printf("access_token_load_error: %i\n", access_token_load_error);
if(access_token_load_error != 0) { // error
char *url = (char *)malloc(sizeof(char) * 150);
int error = TwitterAPI_oauth_request_token_url(url);
printf("URL: %s\n", url);
free(url);
char str[80];
int i;
printf("Enter the PIN: ");
fgets(str, 10, stdin);
/* remove newline, if present */
i = strlen(str)-1;
if( str[ i ] == '\n')
str[i] = '\0';
TwitterAPI_oauth_authorize_from_pin(str);
}
TwitterUser twitter_user;
TwitterUser_initialize(&twitter_user);
twitter_user.screen_name = strdup("testingthis15");
Tweet retweeted_tweet;
Tweet_initialize(&retweeted_tweet);
retweeted_tweet.id_str = strdup("260885034544795651");
Tweet *first_tweet;
int error = TwitterAPI_user_timeline(&first_tweet, &twitter_user);
// int error = TwitterAPI_get_retweets(&retweeted_tweet, &first_tweet);
Tweet *current_tweet = first_tweet;
while(current_tweet != NULL) {
printf("current tweet: %s\n", current_tweet->text);
char *date_str = _relative_time(current_tweet->created_at);
printf("date (%i): %s ago\n", current_tweet->created_at, date_str);
free(date_str);
printf("user name: %s (%s) - %i\n", current_tweet->author->name, current_tweet->author->screen_name, current_tweet->author->id_str);
printf(" id: %s\n\n", current_tweet->id_str);
current_tweet = (Tweet *)current_tweet->next_tweet;
}
error = TwitterAPI_statuses_retweet(&retweeted_tweet);
printf("error retweeting: %i\n", error);
}