Ignore:
Timestamp:
2010-08-07T19:39:01Z (14 years ago)
Author:
Wilmer van der Gaast <wilmer@…>
Branches:
master
Children:
203a2d2
Parents:
daae10f
Message:

Add commands to the Twitter module, starting with undo (which deletes
either your most recent tweet, or a specific id (pass it as an argument)).

File:
1 edited

Legend:

Unmodified
Added
Removed
  • protocols/twitter/twitter_lib.c

    rdaae10f r7b87539  
    736736{
    737737        struct im_connection *ic = req->data;
     738        struct twitter_data *td;
    738739
    739740        // Check if the connection is still active.
     
    741742                return;
    742743
     744        td = ic->proto_data;
     745        td->last_status_id = 0;
     746       
    743747        // Check if the HTTP request went well.
    744748        if (req->status_code != 200) {
     
    746750                imcb_error(ic, "HTTP error: %s", twitter_parse_error(req));
    747751                return;
     752        }
     753       
     754        if (req->body_size > 0)
     755        {
     756                struct xt_parser *xp = NULL;
     757                struct xt_node *node;
     758               
     759                xp = xt_new(NULL, NULL);
     760                xt_feed(xp, req->reply_body, req->body_size);
     761               
     762                if ((node = xt_find_node(xp->root, "status")) &&
     763                    (node = xt_find_node(node->children, "id")) && node->text)
     764                        td->last_status_id = g_ascii_strtoull( node->text, NULL, 10 );
     765               
     766                xt_free(xp);
    748767        }
    749768}
     
    785804        twitter_http(ic, create ? TWITTER_FRIENDSHIPS_CREATE_URL : TWITTER_FRIENDSHIPS_DESTROY_URL, twitter_http_post, ic, 1, args, 2);
    786805}
     806
     807void twitter_status_destroy(struct im_connection *ic, guint64 id)
     808{
     809        char *url;
     810        url = g_strdup_printf("%s%llu%s", TWITTER_STATUS_DESTROY_URL, (unsigned long long) id, ".xml");
     811        twitter_http(ic, url, twitter_http_post, ic, 1, NULL, 0);
     812        g_free(url);
     813}
Note: See TracChangeset for help on using the changeset viewer.