Comments.get

From Facebook Developer Wiki

Jump to: navigation, search

Contents

Description

Returns all comments for a given XID posted through fb:comments or the Comments Box (which is created with the fb:comments (XFBML) tag). This method is a wrapper for the FQL query on the comment FQL table.

You can specify only one XID with this call. If you want to retrieve comments for multiple XIDs, run fql.query against the comment FQL table.

Parameters

RequiredNameTypeDescription
required api_key string The application key associated with the calling application. If you specify the API key in your client, you don't need to pass it with every call.
call_id float The request's sequence number. Each successive call for any session must use a sequence number greater than the last. We suggest using the current time in milliseconds, such as PHP's microtime(true) function. If you specify the call ID in your client, you don't need to pass it with every call.
sig string An MD5 hash of the current request and your secret key, as described in the How Facebook Authenticates Your Application. Facebook computes the signature for you automatically.
v string This must be set to 1.0 to use this version of the API. If you specify the version in your client, you don't need to pass it with every call.
session_key string The session key of the logged in user. The session key is automatically included by our PHP client.
required* xid string The comment xid that you want to retrieve. For a Comments Box, you can determine the xid on the admin panel or in the application settings editor in the Facebook Developer application. 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.
optional format string The desired response format, which can be either XML or JSON. (Default value is XML.)
callback string Name of a function to call. This is primarily to enable cross-domain JavaScript requests using the <script> tag, also known as JSONP, and works with both the XML and JSON formats. The function will be called with the response passed as the parameter.

Example Requests

$facebook->api_client->comments_get('pete_comments');

Example Return XML

<?xml version="1.0" encoding="UTF-8"?> <comments_get_response xmlns="http://api.facebook.com/1.0/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://api.facebook.com/1.0/ http://api.facebook.com/1.0/facebook.xsd" list="true"> <comment> <xid>pete_comments</xid> <fromid>563683308</fromid> <time>1234227529</time> <text>Hola</text> <id>65020</id> </comment> <comment> <xid>pete_comments</xid> <fromid>563683308</fromid> <time>1234227542</time> <text>holla</text> <id>65021</id> </comment> </comments_get_response>

FQL Equivalent

FQL queries take the form: SELECT <fields> FROM <table> WHERE <conditions>

This function is similar (but returned in a slightly different format) to doing the following FQL query, with the appropriate parameters filled in:

SELECT xid, fromid, time, text, id FROM comment WHERE xid=pete_comments

Error Codes

CodeDescription
1700 An unknown error has occurred.
1701 The specified post was too long.
1702 The comments database is down.
1703 The specified xid is not valid. xids can only contain letters, numbers, and underscores
1704 The specified user is not a user of this application
1705 There was an error during posting.

See Also

reference