Stream.getPosts
From Social ID Developers
Revision as of 20:32, 3 June 2016 by Ramon.maciel (Talk | contribs)
Contents |
Description
Searches for approved posts from the stream.
Usage
stream.getPosts(options, handler)
Parameters
handler | optional | callback function to handle the API response. | options | optional | object containing additional parameters. | limit | optional | maximum number of posts to be recovered. | since | optional | Date object with earliest date of creation of posts to be recovered. | until | optional | Date object with latest date of creation of posts to be recovered. | offset | optional | a number to offset results by. |
---|
API Response
data | In case of success, an object containing search results. The object has the following properties: "results", "offset", "count", and "total". | status | API call status. Can be "success" on a successful search, or "internal_server_error" if any unknown error happens. |
---|
Example
Returns all approved posts:
var handler = function(response) { if (response.status == "success") { console.log(response.data.results); } else { alert("Couldn't perform the search."); } } var groupId = 1; var streamId = "productReviews123"; var stream = socialid.comments.getStream(groupId, streamId); stream.getPosts(handler);
Returns the first 10 approved posts, with custom options:
var handler = function(response) { if (response.status == "success") { console.log(response.data.results); } else { alert("Couldn't perform the search."); } } var groupId = 1; var streamId = "productReviews123"; var stream = socialid.comments.getStream(groupId, streamId); var options = { offset: 0, limit: 10, since: new Date("October 13, 2015 11:13:00"), until: new Date("December 31, 2015 00:00:00") }; stream.getPosts(handler, options);
Example "data" object:
data = { count: 1, offset: 0, results: [{ id: 642, comments_group_id: 12, comments_stream_id: 37, status: "approved", stream_external_id: "productReviews123", deleted: false, referer_url: "www.mywebsite.com/product/123", source_ip: "192.168.1.123", comment: "I loved this product", title: "Great!", rating: 5, created_at: "2014-08-28T15:32:20+00:00", updated_at: "2014-08-28T15:32:20+00:00", login_user: { display_name: "Jennyffer Suellen", email: "jennyffer@email.com", id: 5, person_id: 1, picture_url: "https://picture.repository.com/jennyffer.jpg", user_email: "jennyffer@email.com", verified_email: "jennyffer@email.com" } }], total: 1 }
The title, rating, email, user_email, verified_email, picture_url, and display_name properties may return as null depending on the post.