aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--doc/user-guide/commands.xml2
-rw-r--r--protocols/twitter/twitter.c31
-rw-r--r--protocols/twitter/twitter_lib.c6
-rw-r--r--protocols/twitter/twitter_lib.h4
4 files changed, 28 insertions, 15 deletions
diff --git a/doc/user-guide/commands.xml b/doc/user-guide/commands.xml
index 7a36083f..74310d5e 100644
--- a/doc/user-guide/commands.xml
+++ b/doc/user-guide/commands.xml
@@ -770,7 +770,7 @@
</bitlbee-setting>
<bitlbee-setting name="base_url" type="string" scope="account">
- <default>http://twitter.com</default>
+ <default>http://api.twitter.com/1</default>
<description>
<para>
diff --git a/protocols/twitter/twitter.c b/protocols/twitter/twitter.c
index 50a7cc0a..41eabc5a 100644
--- a/protocols/twitter/twitter.c
+++ b/protocols/twitter/twitter.c
@@ -248,7 +248,8 @@ static void twitter_login(account_t * acc)
struct twitter_data *td;
char name[strlen(acc->user) + 9];
url_t url;
-
+ char *s;
+
if (!url_set(&url, set_getstr(&ic->acc->set, "base_url")) ||
(url.proto != PROTO_HTTP && url.proto != PROTO_HTTPS)) {
imcb_error(ic, "Incorrect API base URL: %s", set_getstr(&ic->acc->set, "base_url"));
@@ -256,6 +257,8 @@ static void twitter_login(account_t * acc)
return;
}
+ imcb_log(ic, "Connecting");
+
twitter_connections = g_slist_append(twitter_connections, ic);
td = g_new0(struct twitter_data, 1);
ic->proto_data = td;
@@ -266,13 +269,25 @@ static void twitter_login(account_t * acc)
td->url_host = g_strdup(url.host);
if (strcmp(url.file, "/") != 0)
td->url_path = g_strdup(url.file);
- else
+ else {
td->url_path = g_strdup("");
- if (g_str_has_suffix(url.host, ".com"))
- td->prefix = g_strndup(url.host, strlen(url.host) - 4);
- else
- td->prefix = g_strdup(url.host);
-
+ if (g_str_has_suffix(url.host, "twitter.com"))
+ /* May fire for people who turned on HTTPS. */
+ imcb_error(ic, "Warning: Twitter requires a version number in API calls "
+ "now. Try resetting the base_url account setting.");
+ }
+
+ /* Hacky string mangling: Turn identi.ca into identi.ca and api.twitter.com
+ into twitter, and try to be sensible if we get anything else. */
+ td->prefix = g_strdup(url.host);
+ if (g_str_has_suffix(td->prefix, ".com"))
+ td->prefix[strlen(url.host) - 4] = '\0';
+ if ((s = strrchr(td->prefix, '.'))) {
+ s = g_strdup(s + 1);
+ g_free(td->prefix);
+ td->prefix = s;
+ }
+
if (strstr(acc->pass, "oauth_token="))
td->oauth_info = oauth_from_string(acc->pass, get_oauth_service(ic));
@@ -283,8 +298,6 @@ static void twitter_login(account_t * acc)
if (set_getbool(&acc->set, "show_ids"))
td->log = g_new0(struct twitter_log_data, TWITTER_LOG_LENGTH);
- imcb_log(ic, "Connecting");
-
twitter_login_finish(ic);
}
diff --git a/protocols/twitter/twitter_lib.c b/protocols/twitter/twitter_lib.c
index cc817d45..14e98c53 100644
--- a/protocols/twitter/twitter_lib.c
+++ b/protocols/twitter/twitter_lib.c
@@ -143,7 +143,7 @@ char *twitter_parse_error(struct http_request *req)
{
static char *ret = NULL;
struct xt_parser *xp = NULL;
- struct xt_node *node;
+ struct xt_node *node, *err;
g_free(ret);
ret = NULL;
@@ -153,8 +153,8 @@ char *twitter_parse_error(struct http_request *req)
xt_feed(xp, req->reply_body, req->body_size);
for (node = xp->root; node; node = node->next)
- if ((node = xt_find_node(node->children, "error")) && node->text_len > 0) {
- ret = g_strdup_printf("%s (%s)", req->status_string, node->text);
+ if ((err = xt_find_node(node->children, "error")) && err->text_len > 0) {
+ ret = g_strdup_printf("%s (%s)", req->status_string, err->text);
break;
}
diff --git a/protocols/twitter/twitter_lib.h b/protocols/twitter/twitter_lib.h
index fa039ede..c33b2dfc 100644
--- a/protocols/twitter/twitter_lib.h
+++ b/protocols/twitter/twitter_lib.h
@@ -28,8 +28,8 @@
#include "nogaim.h"
#include "twitter_http.h"
-#define TWITTER_API_URL "http://twitter.com"
-#define IDENTICA_API_URL "http://identi.ca/api"
+#define TWITTER_API_URL "http://api.twitter.com/1"
+#define IDENTICA_API_URL "https://identi.ca/api"
/* Status URLs */
#define TWITTER_STATUS_UPDATE_URL "/statuses/update.xml"