diff options
author | Wilmer van der Gaast <wilmer@gaast.net> | 2010-08-07 20:39:01 +0100 |
---|---|---|
committer | Wilmer van der Gaast <wilmer@gaast.net> | 2010-08-07 20:39:01 +0100 |
commit | 7b87539aedd967884d4e4eed75d1052a233720eb (patch) | |
tree | 404b5801b795c6a0c416f4fce43b1cda51444c9a /protocols/twitter/twitter_lib.c | |
parent | daae10fbfe16bac26f74af91faf253d377f1b166 (diff) |
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)).
Diffstat (limited to 'protocols/twitter/twitter_lib.c')
-rw-r--r-- | protocols/twitter/twitter_lib.c | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/protocols/twitter/twitter_lib.c b/protocols/twitter/twitter_lib.c index 5c89e4f6..a24e9969 100644 --- a/protocols/twitter/twitter_lib.c +++ b/protocols/twitter/twitter_lib.c @@ -735,17 +735,36 @@ void twitter_get_statuses_friends(struct im_connection *ic, gint64 next_cursor) static void twitter_http_post(struct http_request *req) { struct im_connection *ic = req->data; + struct twitter_data *td; // Check if the connection is still active. if( !g_slist_find( twitter_connections, ic ) ) return; + td = ic->proto_data; + td->last_status_id = 0; + // Check if the HTTP request went well. if (req->status_code != 200) { // It didn't go well, output the error and return. imcb_error(ic, "HTTP error: %s", twitter_parse_error(req)); return; } + + if (req->body_size > 0) + { + struct xt_parser *xp = NULL; + struct xt_node *node; + + xp = xt_new(NULL, NULL); + xt_feed(xp, req->reply_body, req->body_size); + + if ((node = xt_find_node(xp->root, "status")) && + (node = xt_find_node(node->children, "id")) && node->text) + td->last_status_id = g_ascii_strtoull( node->text, NULL, 10 ); + + xt_free(xp); + } } /** @@ -784,3 +803,11 @@ void twitter_friendships_create_destroy(struct im_connection *ic, char *who, int args[1] = who; twitter_http(ic, create ? TWITTER_FRIENDSHIPS_CREATE_URL : TWITTER_FRIENDSHIPS_DESTROY_URL, twitter_http_post, ic, 1, args, 2); } + +void twitter_status_destroy(struct im_connection *ic, guint64 id) +{ + char *url; + url = g_strdup_printf("%s%llu%s", TWITTER_STATUS_DESTROY_URL, (unsigned long long) id, ".xml"); + twitter_http(ic, url, twitter_http_post, ic, 1, NULL, 0); + g_free(url); +} |