Comments.add
From Facebook Developer Wiki
Contents |
Description
This method adds a comment to an xid on behalf of a user. This essentially works like stream.addComment and allows addition of comments to an application's fb:comment and Comments Boxes.
Desktop applications must pass a valid session key, and only the user associated with that session key can add comments.
In order for your application to publish a feed story associated with a comment, that user must grant your application the publish_stream extended permission.
Parameters
| Required | Name | Type | Description | |
| required* | xid | string | The xid of a particular Comments Box or fb:comments. You must specify either an xid or an object_id. | |
|---|---|---|---|---|
| object_id | string | The object_id of an object on Facebook. This can be a video, note, link, photo, or photo album. Note that for photos and albums, the object_id must be queried from the photo and album FQL tables. You must specify either an xid or an object_id. | ||
| required | text | string | The comment/text to be added, as inputted by a user. | |
| optional | uid | int | The user ID to add a comment on behalf of. This defaults to the session user and must only be the session user if using a session secret (example: Desktop and JSCL apps). | |
| title | string | The title associated with the item the user is commenting on. This is required if publishing a feed story as it provides the text of the permalink to give context to the user's comment. | ||
| url | string | The url associated with the item the user is commenting on. This is required if publishing a feed story as it is the permalink associated with the comment. | ||
| publish_to_stream | bool | Indicates whether a Feed story should be published about this comment. This defaults to false and can only be 'true' if the user has granted the publish_stream extended permission. | ||
| session_key | string | The session key of the logged in user. The session key is automatically included by our PHP client. Desktop and JavaScript Client Library applications must pass a valid session key. |
Example Requests
$facebook->api_client->comments_add(xid, comment);
Response
This call returns a comment_id if the comment was added successfully, or an error code if the call was unsuccessful.
Notes
You can call this method using a session secret, and not the application secret (for example, for a Facebook Connect site or desktop application).
See Also
- Comments API
- Comment FQL Table
- comments.get - A wrapper around the FQL table.
- comments.remove
