Stream (FQL)
From Facebook Developer Wiki
Contents |
Description
The FQL stream table. Query this table to return posts from a user's stream.
If you want to return all the posts from a user's stream that were published through your application, make sure you include the app_id in your query.
To structure your query, use the table name (stream in this case) in the FROM clause. The items in the Name column correspond to columns in the table that can be referenced in the SELECT and WHERE clauses.
In order to make your query indexable, the WHERE in your query should contain an = or IN clause for one of the columns marked with a * in the Indexable column of the table.
For example to get a viewing user's stream, use SELECT message FROM stream WHERE filter_key="nf".
Columns
| Indexable | Name | Type | Description | |
| * | post_id | string | The ID of the post from the user's stream. This field, when used as an index, is primarily used to re-retrieve posts. Otherwise, it is used to specify a post when using any of the stream setters. | |
|---|---|---|---|---|
| viewer_id | int | The ID of the user whose stream you are querying. The viewer_id defaults to the active session key. | ||
| app_id | int | The application ID for the application through which the post was published. This includes application IDs for Facebook applications like Photos and Video. | ||
| * | source_id | int | The ID of the user, Page, group, or event whose posts you want to retrieve. This includes both posts that the user or Page has authored (that is, the actor_id is the source_id) and posts that have been directed at this target user, Page, group, or event (that is, the target_id is the source_id). | |
| updated_time | time | The time the post was last updated, which occurs when a user comments on the post. | ||
| created_time | time | The time the post was published to the user's stream. | ||
| * | filter_key | string | The filter key to fetch data with. This key should be retrieved from stream.getFilters or querying the stream_filter FQL table. | |
| attribution | string | For posts published by applications, this is the string that states through which application the post was published. For example, "Joe loves the Social Web (by MicroBloggerApp)." | ||
| actor_id | string | The user ID of the person who is the user taking the action in the post. | ||
| target_id | string | The user or Page to whom the post was directed. | ||
| message | string | The message written by the user. | ||
| app_data | array | An array of application-specific information supplied to Facebook to create the attachment to the post. This information is not needed to render a user's stream in your application, unless you need this information for special handing of your own application posts. This array includes:
| ||
| action_links | array | An array containing the text and URL for each action link. | ||
| attachment | array | An array of information about the attachment to the post. This is the attachment that Facebook returns. | ||
| comments | array | A sample array of comments added to a post. This list contains up to two comments to display along with stream content. To get the full list of comments, use stream.getComments or query the comment FQL table using the post_id of this post. The array contains the following fields:
| ||
| likes | array | An array of likes associated with the post. The array contains the following fields:
| ||
| privacy | array | The privacy setting for a post, indicating which of a user's friends or others can see the content. | ||
| type | string | Do not use this field as it's been deprecated. To determine what sort of post gets returned, look for the presence of an attachment (lack of an attachment indicates a status update), and if one is present, look at the attachment's media type (photo, Flash, mp3) to determine how you want to handle the post. Facebook for Adobe AIR uses this method, for example. | ||
| permalink | string | A link to the stream post. | ||
| tagged_ids | array | An array of ids that are referred to in the story. Currently, this is commonly encountered in stories about photo tags. | ||
| is_hidden | bool | A flag indicating whether the specified post has been hidden by the viewing user |
Examples
Get the visible stream of all of a user's connections (regardless of following status).
Retrieve a user's home page stream (News Feed) based on the user's following status for his or her connections.
A typical use case for the stream table using a filter_key from the stream_filter FQL table, in this case retrieving the user's News Feed.
Refresh posts by getting new posts newer than some time.
Get posts before current set of posts. (use in place of OFFSET).
Retrieve a user's wall posts (stories on their profile).
Retrieve the action links in a user's stream, and remove any HTML markup and encoding.
Notes
- If you want to remove any HTML markup and encoding for a field in your query (for example, in an attachment), pass the field as a parameter to the
strip_tagsfunction. You can specify this function more than once if you want to remove markup from multiple fields. - The OFFSET FQL parameter does not work for the stream table (and doesn't really make sense as posts are always being inserted into the stream). To get an "offset" number of posts, query with a time range prior to the oldest time of your current set of posts. Similarly, to get updated posts, specify a time range after the newest time of your current set of posts.
- You can only make 100 calls to stream per 600 seconds.
