str = ws_reply_get_error(content);
if (str) {
- *err = strdup(str);
+ log_debug("execute() err=%s", str);
content = NULL;
+
+ if (err)
+ *err = strdup(str);
} else {
json_object_get(content);
}
json_object_put(rp);
}
+ log_debug("execute() done");
+
return content;
}
return result;
}
-char *ws_get_article_content(int id)
+struct json_object *ws_request_new_get_article_content(int id)
{
- struct json_object *rp, *rq, *content, *item;
- char *str;
+ struct json_object *rq;
rq = ws_request_new("getArticle");
ws_request_add_att_int(rq, "article_id", id);
- rp = ws_execute(rq);
-
- json_object_put(rq);
+ return rq;
+}
- str = NULL;
+const char *ws_reply_get_article_content(struct json_object *rp)
+{
+ struct json_object *item, *content;
if (rp) {
item = json_object_array_get_idx(rp, 0);
if (item) {
content = json_object_object_get(item, "content");
- str = strdup(json_object_get_string(content));
+ return json_object_get_string(content);
}
+ }
- json_object_put(rp);
+ return NULL;
+}
+
+char *ws_get_article_content(int id)
+{
+ struct json_object *rp, *rq;
+ const char *content;
+ char *str;
+
+ rq = ws_request_new("getArticle");
+ ws_request_add_att_int(rq, "article_id", id);
+
+ rp = ws_execute(rq);
+
+ json_object_put(rq);
+
+ if (rp) {
+ content = ws_reply_get_article_content(rp);
+
+ if (content) {
+ str = strdup(content);
+ json_object_put(rp);
+ return str;
+ }
}
- return str;
+ return NULL;
}
int ws_update_headlines(struct feed *feed)
rq = ws_request_new("getHeadlines");
ws_request_add_att_int(rq, "feed_id", feed->id);
- ws_request_add_att_bool(rq, "show_excerpt", 1);
rp = ws_execute(rq);
h = headline_new(hid, url, title);
j = json_object_object_get(jheadline,
- "excerpt");
- h->excerpt = strdup(json_object_get_string(j));
-
- j = json_object_object_get(jheadline,
"updated");
h->date = json_object_get_int(j);