Ignore:
Timestamp:
2015-06-08T03:42:11Z (9 years ago)
Author:
dequis <dx@…>
Branches:
master
Children:
53c7799
Parents:
61e7e02
Message:

twitter: show full url in the url command, with username

By asking the server for the username.

Storing the username somewhere would have made sense, but this command
isn't going to be used very often, so, whatever.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • protocols/twitter/twitter_lib.c

    r61e7e02 r1201fcb  
    15731573        g_free(args[1]);
    15741574}
     1575
     1576static void twitter_http_status_show_url(struct http_request *req)
     1577{
     1578        struct im_connection *ic = req->data;
     1579        json_value *parsed, *id;
     1580        const char *name;
     1581
     1582        // Check if the connection is still active.
     1583        if (!g_slist_find(twitter_connections, ic)) {
     1584                return;
     1585        }
     1586
     1587        if (!(parsed = twitter_parse_response(ic, req))) {
     1588                return;
     1589        }
     1590
     1591        /* for the parson branch:
     1592        name = json_object_dotget_string(json_object(parsed), "user.screen_name");
     1593        id = json_object_get_integer(json_object(parsed), "id");
     1594        */
     1595
     1596        name = json_o_str(json_o_get(parsed, "user"), "screen_name");
     1597        id = json_o_get(parsed, "id");
     1598
     1599        if (name && id && id->type == json_integer) {
     1600                twitter_log(ic, "https://twitter.com/%s/status/%" G_GUINT64_FORMAT, name, id->u.integer);
     1601        } else {
     1602                twitter_log(ic, "Error: could not fetch tweet url.");
     1603        }
     1604
     1605        json_value_free(parsed);
     1606}
     1607
     1608void twitter_status_show_url(struct im_connection *ic, guint64 id)
     1609{
     1610        char *url = g_strdup_printf("%s%" G_GUINT64_FORMAT "%s", TWITTER_STATUS_SHOW_URL, id, ".json");
     1611        twitter_http(ic, url, twitter_http_status_show_url, ic, 0, NULL, 0);
     1612        g_free(url);
     1613}
Note: See TracChangeset for help on using the changeset viewer.