diff options
Diffstat (limited to 'protocols/twitter/twitter_lib.c')
-rw-r--r-- | protocols/twitter/twitter_lib.c | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/protocols/twitter/twitter_lib.c b/protocols/twitter/twitter_lib.c index 17bceb9f..40adb992 100644 --- a/protocols/twitter/twitter_lib.c +++ b/protocols/twitter/twitter_lib.c @@ -1572,3 +1572,42 @@ void twitter_favourite_tweet(struct im_connection *ic, guint64 id) ic, 1, args, 2, TWITTER_HTTP_USER_ACK); g_free(args[1]); } + +static void twitter_http_status_show_url(struct http_request *req) +{ + struct im_connection *ic = req->data; + json_value *parsed, *id; + const char *name; + + // Check if the connection is still active. + if (!g_slist_find(twitter_connections, ic)) { + return; + } + + if (!(parsed = twitter_parse_response(ic, req))) { + return; + } + + /* for the parson branch: + name = json_object_dotget_string(json_object(parsed), "user.screen_name"); + id = json_object_get_integer(json_object(parsed), "id"); + */ + + name = json_o_str(json_o_get(parsed, "user"), "screen_name"); + id = json_o_get(parsed, "id"); + + if (name && id && id->type == json_integer) { + twitter_log(ic, "https://twitter.com/%s/status/%" G_GUINT64_FORMAT, name, id->u.integer); + } else { + twitter_log(ic, "Error: could not fetch tweet url."); + } + + json_value_free(parsed); +} + +void twitter_status_show_url(struct im_connection *ic, guint64 id) +{ + char *url = g_strdup_printf("%s%" G_GUINT64_FORMAT "%s", TWITTER_STATUS_SHOW_URL, id, ".json"); + twitter_http(ic, url, twitter_http_status_show_url, ic, 0, NULL, 0); + g_free(url); +} |