- Timestamp:
- 2010-04-26T00:42:37Z (15 years ago)
- Branches:
- master
- Children:
- acba168
- Parents:
- b2bc25c
- Location:
- protocols/twitter
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
protocols/twitter/twitter.c
rb2bc25c r508c340 82 82 83 83 td->user = acc->user; 84 td->pass = acc->pass; 84 if( strstr( acc->pass, "oauth_token=" ) == NULL ) 85 td->pass = g_strdup( acc->pass ); 86 else 87 td->oauth = g_strdup( acc->pass ); 85 88 td->home_timeline_id = 0; 86 89 … … 119 122 if( td ) 120 123 { 124 g_free( td->pass ); 125 g_free( td->oauth ); 121 126 g_free( td ); 122 127 } -
protocols/twitter/twitter.h
rb2bc25c r508c340 37 37 char* user; 38 38 char* pass; 39 char* oauth; 39 40 guint64 home_timeline_id; 40 41 gint main_loop_id; -
protocols/twitter/twitter_http.c
rb2bc25c r508c340 35 35 #include "misc.h" 36 36 #include "base64.h" 37 #include "oauth.h" 37 38 #include <ctype.h> 38 39 #include <errno.h> … … 45 46 * This is actually pretty generic function... Perhaps it should move to the lib/http_client.c 46 47 */ 47 void *twitter_http(char *url_string, http_input_function func, gpointer data, int is_post, char* user, char* pass, char* * arguments, int arguments_len)48 void *twitter_http(char *url_string, http_input_function func, gpointer data, int is_post, char* user, char* pass, char* oauth_token, char** arguments, int arguments_len) 48 49 { 49 50 url_t *url = g_new0( url_t, 1 ); … … 110 111 111 112 // If a pass and user are given we append them to the request. 112 if (userpass_base64) 113 if (oauth_token) 114 { 115 char *full_header; 116 117 full_header = oauth_http_header(oauth_token, 118 is_post ? "POST" : "GET", 119 url_string, url_arguments); 120 121 tmp = g_strdup_printf("%sAuthorization: %s\r\n", request, full_header); 122 g_free(request); 123 g_free(full_header); 124 request = tmp; 125 } 126 else if (userpass_base64) 113 127 { 114 128 tmp = g_strdup_printf("%sAuthorization: Basic %s\r\n", request, userpass_base64); -
protocols/twitter/twitter_http.h
rb2bc25c r508c340 29 29 30 30 void *twitter_http(char *url_string, http_input_function func, gpointer data, int is_post, 31 char* user, char* pass, char** arguments, int arguments_len);31 char* user, char* pass, char *oauth_token, char** arguments, int arguments_len); 32 32 33 33 #endif //_TWITTER_HTTP_H -
protocols/twitter/twitter_lib.c
rb2bc25c r508c340 130 130 args[0] = "cursor"; 131 131 args[1] = g_strdup_printf ("%d", next_cursor); 132 twitter_http(TWITTER_FRIENDS_IDS_URL, twitter_http_get_friends_ids, ic, 0, td->user, td->pass, args, 2);132 twitter_http(TWITTER_FRIENDS_IDS_URL, twitter_http_get_friends_ids, ic, 0, td->user, td->pass, td->oauth, args, 2); 133 133 134 134 g_free(args[1]); … … 396 396 } 397 397 398 twitter_http(TWITTER_HOME_TIMELINE_URL, twitter_http_get_home_timeline, ic, 0, td->user, td->pass, args, td->home_timeline_id ? 4 : 2);398 twitter_http(TWITTER_HOME_TIMELINE_URL, twitter_http_get_home_timeline, ic, 0, td->user, td->pass, td->oauth, args, td->home_timeline_id ? 4 : 2); 399 399 400 400 g_free(args[1]); … … 620 620 args[1] = g_strdup_printf ("%d", next_cursor); 621 621 622 twitter_http(TWITTER_SHOW_FRIENDS_URL, twitter_http_get_statuses_friends, ic, 0, td->user, td->pass, args, 2);622 twitter_http(TWITTER_SHOW_FRIENDS_URL, twitter_http_get_statuses_friends, ic, 0, td->user, td->pass, td->oauth, args, 2); 623 623 624 624 g_free(args[1]); … … 654 654 args[0] = "status"; 655 655 args[1] = msg; 656 twitter_http(TWITTER_STATUS_UPDATE_URL, twitter_http_post_status, ic, 1, td->user, td->pass, args, 2);656 twitter_http(TWITTER_STATUS_UPDATE_URL, twitter_http_post_status, ic, 1, td->user, td->pass, td->oauth, args, 2); 657 657 // g_free(args[1]); 658 658 } … … 672 672 args[3] = msg; 673 673 // Use the same callback as for twitter_post_status, since it does basically the same. 674 twitter_http(TWITTER_DIRECT_MESSAGES_NEW_URL, twitter_http_post_status, ic, 1, td->user, td->pass, args, 4);674 twitter_http(TWITTER_DIRECT_MESSAGES_NEW_URL, twitter_http_post_status, ic, 1, td->user, td->pass, td->oauth, args, 4); 675 675 // g_free(args[1]); 676 676 // g_free(args[3]);
Note: See TracChangeset
for help on using the changeset viewer.