Stream.createPost
From Social ID Developers
Contents |
Description
Creates a new post in name of the currently logged in user and, if needed, sends it to moderation.
Usage
stream.createPost(post, handler)
Parameters
handler | optional | callback function to handle the API response. | post | required | object containing post parameters. | title | optional | string containing post title. | comment | optional | string containing post text content. | rating | optional | integer from 1 to 5 with post rating (stars). |
---|
API Response
data | In case of success, an object containing the created post data. | status | API call status. Can be "success" on a successful operation, "unprocessable_entity" if there are validation problems with the post, or "internal_server_error" if any unknown error happens. |
---|
Example
Create a simple Comment on the stream:
var handler = function(response) { if (response.status == "success") { console.log(response.data); } else { alert("Couldn't create the post."); } } var groupId = 1; var streamId = "productReviews456"; var stream = socialid.comments.getStream(groupId, streamId); var post = { comment: "Lorem ipsum dolor sit amet, consectetur adipiscing elit" }; stream.createPost(post, handler);
Create a Rating/Review on the stream:
var handler = function(response) { if (response.status == "success") { console.log(response.data); } else { alert("Couldn't create the post."); } } var groupId = 1; var streamId = "productReviews456"; var stream = socialid.comments.getStream(groupId, streamId); var post = { title: "Review title", rating: 4, comment: "Lorem ipsum dolor sit amet, consectetur adipiscing elit" }; stream.createPost(post, handler);