- struct json_object *rp, *rq, *content, *jheadline, *j;
- int i, n;
- struct headline **headlines, *h;
-
- printf("get_headlines %d\n", feed_id);
-
- rq = create_op("getHeadlines");
- json_object_object_add(rq, "feed_id", json_object_new_int(feed_id));
-
- 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, "id");
- h->id = json_object_get_int(j);
-
- j = json_object_object_get(jheadline, "title");
- h->title = strdup(json_object_get_string(j));
-
- j = json_object_object_get(jheadline, "link");
- h->url = strdup(json_object_get_string(j));