diff options
Diffstat (limited to 'protocols/twitter/twitter.c')
-rw-r--r-- | protocols/twitter/twitter.c | 26 |
1 files changed, 24 insertions, 2 deletions
diff --git a/protocols/twitter/twitter.c b/protocols/twitter/twitter.c index dbe9b984..63f648df 100644 --- a/protocols/twitter/twitter.c +++ b/protocols/twitter/twitter.c @@ -98,15 +98,37 @@ static const struct oauth_service twitter_oauth = .consumer_secret = "FCxqcr0pXKzsF9ajmP57S3VQ8V6Drk4o2QYtqMcOszo", }; +static const struct oauth_service identica_oauth = +{ + "http://identi.ca/api/oauth/request_token", + "http://identi.ca/api/oauth/access_token", + "https://identi.ca/api/oauth/authorize", + .consumer_key = "e147ff789fcbd8a5a07963afbb43f9da", + .consumer_secret = "c596267f277457ec0ce1ab7bb788d828", +}; + static gboolean twitter_oauth_callback( struct oauth_info *info ); +static const struct oauth_service *get_oauth_service( struct im_connection *ic ) +{ + struct twitter_data *td = ic->proto_data; + + if( strstr( td->url_host, "identi.ca" ) ) + return &identica_oauth; + else + return &twitter_oauth; + + /* Could add more services, or allow configuring your own base URL + + API keys. */ +} + static void twitter_oauth_start( struct im_connection *ic ) { struct twitter_data *td = ic->proto_data; imcb_log( ic, "Requesting OAuth request token" ); - td->oauth_info = oauth_request_token( &twitter_oauth, twitter_oauth_callback, ic ); + td->oauth_info = oauth_request_token( get_oauth_service( ic ), twitter_oauth_callback, ic ); /* We need help from the user to complete OAuth login, so don't time out on this login. */ @@ -262,7 +284,7 @@ static void twitter_login( account_t *acc ) td->user = acc->user; if( strstr( acc->pass, "oauth_token=" ) ) - td->oauth_info = oauth_from_string( acc->pass, &twitter_oauth ); + td->oauth_info = oauth_from_string( acc->pass, get_oauth_service( ic ) ); sprintf( name, "%s_%s", td->prefix, acc->user ); imcb_add_buddy( ic, name, NULL ); |