Changeset c0f33f1 for protocols/twitter


Ignore:
Timestamp:
2011-06-11T17:50:26Z (14 years ago)
Author:
Wilmer van der Gaast <wilmer@…>
Branches:
master
Children:
4bc66ae
Parents:
de923d5
Message:

Change the default base_url to something that works. Change the default for
identi.ca to HTTPS while I'm at it. Pretty important since I can't use OAuth
for it yet.

Location:
protocols/twitter
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • protocols/twitter/twitter.c

    rde923d5 rc0f33f1  
    249249        char name[strlen(acc->user) + 9];
    250250        url_t url;
    251 
     251        char *s;
     252       
    252253        if (!url_set(&url, set_getstr(&ic->acc->set, "base_url")) ||
    253254            (url.proto != PROTO_HTTP && url.proto != PROTO_HTTPS)) {
     
    257258        }
    258259
     260        imcb_log(ic, "Connecting");
     261
    259262        twitter_connections = g_slist_append(twitter_connections, ic);
    260263        td = g_new0(struct twitter_data, 1);
     
    267270        if (strcmp(url.file, "/") != 0)
    268271                td->url_path = g_strdup(url.file);
    269         else
     272        else {
    270273                td->url_path = g_strdup("");
    271         if (g_str_has_suffix(url.host, ".com"))
    272                 td->prefix = g_strndup(url.host, strlen(url.host) - 4);
    273         else
    274                 td->prefix = g_strdup(url.host);
    275 
     274                if (g_str_has_suffix(url.host, "twitter.com"))
     275                        /* May fire for people who turned on HTTPS. */
     276                        imcb_error(ic, "Warning: Twitter requires a version number in API calls "
     277                                       "now. Try resetting the base_url account setting.");
     278        }
     279       
     280        /* Hacky string mangling: Turn identi.ca into identi.ca and api.twitter.com
     281           into twitter, and try to be sensible if we get anything else. */
     282        td->prefix = g_strdup(url.host);
     283        if (g_str_has_suffix(td->prefix, ".com"))
     284                td->prefix[strlen(url.host) - 4] = '\0';
     285        if ((s = strrchr(td->prefix, '.'))) {
     286                s = g_strdup(s + 1);
     287                g_free(td->prefix);
     288                td->prefix = s;
     289        }
     290       
    276291        if (strstr(acc->pass, "oauth_token="))
    277292                td->oauth_info = oauth_from_string(acc->pass, get_oauth_service(ic));
     
    283298        if (set_getbool(&acc->set, "show_ids"))
    284299                td->log = g_new0(struct twitter_log_data, TWITTER_LOG_LENGTH);
    285 
    286         imcb_log(ic, "Connecting");
    287300
    288301        twitter_login_finish(ic);
  • protocols/twitter/twitter_lib.c

    rde923d5 rc0f33f1  
    144144        static char *ret = NULL;
    145145        struct xt_parser *xp = NULL;
    146         struct xt_node *node;
     146        struct xt_node *node, *err;
    147147
    148148        g_free(ret);
     
    154154               
    155155                for (node = xp->root; node; node = node->next)
    156                         if ((node = xt_find_node(node->children, "error")) && node->text_len > 0) {
    157                                 ret = g_strdup_printf("%s (%s)", req->status_string, node->text);
     156                        if ((err = xt_find_node(node->children, "error")) && err->text_len > 0) {
     157                                ret = g_strdup_printf("%s (%s)", req->status_string, err->text);
    158158                                break;
    159159                        }
  • protocols/twitter/twitter_lib.h

    rde923d5 rc0f33f1  
    2929#include "twitter_http.h"
    3030
    31 #define TWITTER_API_URL "http://twitter.com"
    32 #define IDENTICA_API_URL "http://identi.ca/api"
     31#define TWITTER_API_URL "http://api.twitter.com/1"
     32#define IDENTICA_API_URL "https://identi.ca/api"
    3333
    3434/* Status URLs */
Note: See TracChangeset for help on using the changeset viewer.