Changeset fb351ce


Ignore:
Timestamp:
2012-11-09T00:07:23Z (12 years ago)
Author:
Wilmer van der Gaast <wilmer@…>
Branches:
master
Children:
5246133
Parents:
8e3b7ac
Message:

Getting better. Corruption fixed, fetching of mentions fixed, error handling
"fixed".

Location:
protocols/twitter
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • protocols/twitter/twitter_lib.c

    r8e3b7ac rfb351ce  
    174174        ret = NULL;
    175175
     176        /* EX:
     177        {"errors":[{"message":"Rate limit exceeded","code":88}]} */
    176178        if (req->body_size > 0) {
    177179                root = xt_from_string(req->reply_body, req->body_size);
     
    189191}
    190192
    191 /* TODO: NULL means failure, but not always that the connection is dead. This sucks for callers. */
     193/* WATCH OUT: This function might or might not destroy your connection.
     194   Sub-optimal indeed, but just be careful when this returns NULL! */
    192195static json_value *twitter_parse_response(struct im_connection *ic, struct http_request *req)
    193196{
     
    457460static xt_status twitter_xt_get_status(const json_value *node, struct twitter_xml_status *txs)
    458461{
    459         const json_value *c, *rt = NULL, *entities = NULL;
     462        const json_value *rt = NULL, *entities = NULL;
    460463        int i;
    461464       
     
    468471               
    469472                if (strcmp("text", k) == 0 && v->type == json_string) {
    470                         txs->text = g_memdup(v->u.string.ptr, v->u.string.length);
     473                        txs->text = g_memdup(v->u.string.ptr, v->u.string.length + 1);
    471474                } else if (strcmp("retweeted_status", k) == 0 && v->type == json_object) {
    472475                        rt = v;
     
    486489                        txs->reply_to = v->u.integer;
    487490                } else if (strcmp("entities", k) == 0 && v->type == json_object) {
    488                         txs->reply_to = v->u.integer;
     491                        entities = v;
    489492                }
    490493        }
     
    502505                txs->text = g_strdup_printf("RT @%s: %s", rtxs->user->screen_name, rtxs->text);
    503506                txs_free(rtxs);
    504         } else if (entities && NULL) {
     507        } else if (entities) {
    505508                JSON_O_FOREACH (entities, k, v) {
    506509                        int i;
     
    545548{
    546549        struct twitter_xml_status *txs;
    547         json_value *c;
    548550        bee_user_t *bu;
    549551        int i;
     
    917919
    918920      end:
     921        if (!g_slist_find(twitter_connections, ic))
     922                return;
     923
    919924        td->flags |= TWITTER_GOT_TIMELINE;
    920925
     
    950955
    951956      end:
     957        if (!g_slist_find(twitter_connections, ic))
     958                return;
     959
    952960        td->flags |= TWITTER_GOT_MENTIONS;
    953961
  • protocols/twitter/twitter_lib.h

    r8e3b7ac rfb351ce  
    4343#define TWITTER_FRIENDS_TIMELINE_URL "/statuses/friends_timeline.json"
    4444#define TWITTER_HOME_TIMELINE_URL "/statuses/home_timeline.json"
    45 #define TWITTER_MENTIONS_URL "/statuses/mentions.json"
     45#define TWITTER_MENTIONS_URL "/statuses/mentions_timeline.json"
    4646#define TWITTER_USER_TIMELINE_URL "/statuses/user_timeline.json"
    4747
Note: See TracChangeset for help on using the changeset viewer.