Changeset 3b878a1 for protocols/twitter/twitter.c
- Timestamp:
- 2010-05-02T21:20:09Z (14 years ago)
- Branches:
- master
- Children:
- 6824fb3
- Parents:
- 839189b (diff), f4b0911 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
protocols/twitter/twitter.c
r839189b r3b878a1 28 28 #include "twitter_lib.h" 29 29 30 31 30 /** 32 31 * Main loop function … … 66 65 } 67 66 67 68 static const struct oauth_service twitter_oauth = 69 { 70 "http://api.twitter.com/oauth/request_token", 71 "http://api.twitter.com/oauth/access_token", 72 "http://api.twitter.com/oauth/authorize", 73 .consumer_key = "xsDNKJuNZYkZyMcu914uEA", 74 .consumer_secret = "FCxqcr0pXKzsF9ajmP57S3VQ8V6Drk4o2QYtqMcOszo", 75 }; 76 68 77 static gboolean twitter_oauth_callback( struct oauth_info *info ); 69 78 … … 74 83 imcb_log( ic, "Requesting OAuth request token" ); 75 84 76 td->oauth_info = oauth_request_token( 77 TWITTER_OAUTH_REQUEST_TOKEN, twitter_oauth_callback, ic ); 85 td->oauth_info = oauth_request_token( &twitter_oauth, twitter_oauth_callback, ic ); 78 86 } 79 87 … … 100 108 sprintf( name, "twitter_%s", ic->acc->user ); 101 109 msg = g_strdup_printf( "To finish OAuth authentication, please visit " 102 "%s ?%sand respond with the resulting PIN code.",103 TWITTER_OAUTH_AUTHORIZE, info->auth_params);110 "%s and respond with the resulting PIN code.", 111 info->auth_url ); 104 112 imcb_buddy_msg( ic, name, msg, 0, 0 ); 105 113 g_free( msg ); … … 107 115 else if( info->stage == OAUTH_ACCESS_TOKEN ) 108 116 { 109 if( info-> access_token== NULL )117 if( info->token == NULL || info->token_secret == NULL ) 110 118 { 111 119 imcb_error( ic, "OAuth error: %s", info->http->status_string ); … … 114 122 } 115 123 116 td->oauth = g_strdup( info->access_token );117 118 124 /* IM mods didn't do this so far and it's ugly but I should 119 125 be able to get away with it... */ 120 126 g_free( ic->acc->pass ); 121 ic->acc->pass = g_strdup( info->access_token);127 ic->acc->pass = oauth_to_string( info ); 122 128 123 129 twitter_main_loop_start( ic ); … … 126 132 return TRUE; 127 133 } 134 128 135 129 136 static char *set_eval_mode( set_t *set, char *value ) … … 165 172 td->pass = g_strdup( acc->pass ); 166 173 else if( strstr( acc->pass, "oauth_token=" ) ) 167 td->oauth = g_strdup( acc->pass);174 td->oauth_info = oauth_from_string( acc->pass, &twitter_oauth ); 168 175 td->home_timeline_id = 0; 169 176 … … 172 179 imcb_buddy_status( ic, name, OPT_LOGGED_IN, NULL, NULL ); 173 180 174 if( td->pass || td->oauth )181 if( td->pass || td->oauth_info ) 175 182 twitter_main_loop_start( ic ); 176 183 else … … 197 204 { 198 205 oauth_info_free( td->oauth_info ); 199 200 206 g_free( td->pass ); 201 g_free( td->oauth );202 207 g_free( td ); 203 208 } … … 216 221 g_strcasecmp(who + 8, ic->acc->user) == 0) 217 222 { 218 if( set_getbool( &ic->acc->set, "oauth" ) && td->oauth_info ) 223 if( set_getbool( &ic->acc->set, "oauth" ) && 224 td->oauth_info && td->oauth_info->token == NULL ) 219 225 { 220 oauth_access_token( TWITTER_OAUTH_ACCESS_TOKEN, message, td->oauth_info ); 221 td->oauth_info = NULL; 226 if( !oauth_access_token( message, td->oauth_info ) ) 227 { 228 imcb_error( ic, "OAuth error: %s", "Failed to send access token request" ); 229 imc_logout( ic, TRUE ); 230 return FALSE; 231 } 222 232 } 223 233 else
Note: See TracChangeset
for help on using the changeset viewer.