- struct json_object *rp, *rq, *content, *jheadline, *j;
- int i, n;
- struct headline **headlines, *h;
-
- rq = create_op("getHeadlines");
- json_object_object_add(rq, "feed_id", json_object_new_int(feed_id));
- json_object_object_add(rq, "show_excerpt", json_object_new_boolean(1));
- json_object_object_add(rq, "show_content", json_object_new_boolean(1));
-
- rp = post_json_object(session_url, rq);
-
- json_object_put(rq);
-
- content = json_object_object_get(rp, "content");
-
- if (content) {
- n = json_object_array_length(content);
- headlines = malloc((n+1)*sizeof(struct headline *));
- for (i = 0; i < n; i++) {
- jheadline = json_object_array_get_idx(content, i);
-
- h = malloc(sizeof(struct headline));
-
- j = json_object_object_get(jheadline, "title");
- h->title = strdup(json_object_get_string(j));
-
- j = json_object_object_get(jheadline, "excerpt");
- h->excerpt = strdup(json_object_get_string(j));
-
- j = json_object_object_get(jheadline, "content");
- h->content = strdup(json_object_get_string(j));
-
- headlines[i] = h;
- }
- headlines[n] = NULL;
- } else {
- headlines = NULL;
- }