Stream.getPosts
(Difference between revisions)
Ramon.maciel (Talk | contribs) |
Ramon.maciel (Talk | contribs) (→Example) |
||
Line 88: | Line 88: | ||
results: [{ | results: [{ | ||
id: 642, | id: 642, | ||
− | + | group_id: 12, | |
− | + | stream_id: "productReviews123", | |
status: "approved", | status: "approved", | ||
− | |||
− | |||
referer_url: "www.mywebsite.com/product/123", | referer_url: "www.mywebsite.com/product/123", | ||
− | |||
comment: "I loved this product", | comment: "I loved this product", | ||
title: "Great!", | title: "Great!", | ||
Line 104: | Line 101: | ||
email: "jennyffer@email.com", | email: "jennyffer@email.com", | ||
id: 5, | id: 5, | ||
− | |||
picture_url: "https://picture.repository.com/jennyffer.jpg", | picture_url: "https://picture.repository.com/jennyffer.jpg", | ||
user_email: "jennyffer@email.com", | user_email: "jennyffer@email.com", |
Revision as of 17:58, 6 June 2016
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 = "productReviews456"; 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(options, handler);
Example "data" object:
data = { count: 1, offset: 0, results: [{ id: 642, group_id: 12, stream_id: "productReviews123", status: "approved", referer_url: "www.mywebsite.com/product/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, 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.