aboutsummaryrefslogtreecommitdiffstats
path: root/protocols/twitter/twitter_lib.c
diff options
context:
space:
mode:
Diffstat (limited to 'protocols/twitter/twitter_lib.c')
-rw-r--r--protocols/twitter/twitter_lib.c60
1 files changed, 60 insertions, 0 deletions
diff --git a/protocols/twitter/twitter_lib.c b/protocols/twitter/twitter_lib.c
index b69c532e..bffd61aa 100644
--- a/protocols/twitter/twitter_lib.c
+++ b/protocols/twitter/twitter_lib.c
@@ -1836,3 +1836,63 @@ void twitter_status_show_url(struct im_connection *ic, guint64 id)
twitter_http(ic, url, twitter_http_status_show_url, ic, 0, NULL, 0);
g_free(url);
}
+
+struct twitter_http_msg {
+ struct im_connection *ic;
+ char *message;
+};
+
+static void twitter_http_status_quote_post(struct http_request *req)
+{
+ struct twitter_http_msg *thm = req->data;
+ struct im_connection *ic = thm->ic;
+ struct twitter_data *td = ic->proto_data;
+ char *message;
+ const char *name;
+ json_value *parsed, *id;
+
+ if (!g_slist_find(twitter_connections, ic)) {
+ goto eof;
+ }
+
+ if (!(parsed = twitter_parse_response(ic, req))) {
+ goto eof;
+ }
+
+ name = json_o_str(json_o_get(parsed, "user"), "screen_name");
+ id = json_o_get(parsed, "id");
+
+ if (name && id && id->type == json_integer) {
+ message = g_strdup_printf("%s https://twitter.com/%s/status/%" G_GUINT64_FORMAT, thm->message, name, id->u.integer);
+
+ /*if (!twitter_length_check(ic, message)) {
+ goto eof;
+ }*/
+
+ td->last_status_id = 0;
+ twitter_post_status(ic, message, 0);
+ } else {
+ twitter_log(ic, "Error: could not fetch url for quoted tweet.");
+ }
+
+ json_value_free(parsed);
+
+eof:
+ g_free(thm->message);
+ g_free(thm);
+}
+
+void twitter_status_quote_post(struct im_connection *ic, guint64 id, char *message)
+{
+ struct twitter_http_msg *thm;
+ char *url;
+
+ thm = g_new0(struct twitter_http_msg, 1);
+
+ thm->ic = ic;
+ thm->message = g_strdup(message);
+
+ url = g_strdup_printf("%s%" G_GUINT64_FORMAT "%s", TWITTER_STATUS_SHOW_URL, id, ".json");
+ twitter_http(ic, url, twitter_http_status_quote_post, thm, 0, NULL, 0);
+ g_free(url);
+}