Links.get
From Facebook Developer Wiki
Contents |
Description
Returns all links the user has posted on their profile through your application.
For desktop applications, this call works only for the logged-in user, since that's the only session you have. If you want data for other users, make an FQL query (fql.query) on the link (FQL) table.
Parameters
| Required | Name | Type | Description | |
| 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. | ||
| 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. | ||
| uid | int | The user ID of the user whose links you want to retrieve. For desktop applications, don't specify a uid; keep the default. (Default value is the logged-in user.) | ||
| link_ids | array | An array of link IDs for the links you want to return. | ||
| limit | string | The number of links to retrieve, in reverse chronological order, from most recent to oldest. (Default value is 50.) |
Example Requests
$facebook->api_client->links_get($uid, $link_ids, $limit);
Response
This method returns an array of link data.
Example Return JSON
[{"link_id":123318077647,"owner":563683308,"owner_comment":"Last one, I promise.","created_time":1251822717,"title":"Outside Lands 2009 60 - Stereogum",
"summary":"\u00a9 2009 Stereogum - All Rights Reserved Terms & Conditions | Privacy | About Stereogum | Powered by Buzznet",
"url":"http:\/\/stereogum.com\/archives\/photo\/outside-lands-2009-in-photos_087531.html?img=58&gfmt=e",
"image_urls":["http:\/\/stereogum.com\/img\/gallery\/2009\/09\/outside_lands_2009\/gallery_enlarged\/gallery_enlarged-heartless-bastards-pete-bratach-7114.jpg"]},
{"link_id":150223951284,"owner":563683308,"owner_comment":"Yet another self-congratulatory post!","created_time":1251822681,"title":"Outside Lands 2009 58 - Stereogum",
"summary":"\u00a9 2009 Stereogum - All Rights Reserved Terms & Conditions | Privacy | About Stereogum | Powered by Buzznet",
"url":"http:\/\/stereogum.com\/archives\/photo\/outside-lands-2009-in-photos_087531.html?img=56&gfmt=e",
"image_urls":["http:\/\/stereogum.com\/img\/gallery\/2009\/09\/outside_lands_2009\/gallery_enlarged\/gallery_enlarged-calexico-pete-bratach-1.jpg"]},
{"link_id":127117035741,"owner":563683308,"owner_comment":"Yay, I got published on Stereogum!","created_time":1251822650,"title":"Outside Lands 2009 57 - Stereogum",
"summary":"\u00a9 2009 Stereogum - All Rights Reserved Terms & Conditions | Privacy | About Stereogum | Powered by Buzznet",
"url":"http:\/\/stereogum.com\/archives\/photo\/outside-lands-2009-in-photos_087531.html?img=55&gfmt=e",
"image_urls":["http:\/\/stereogum.com\/img\/gallery\/2009\/09\/outside_lands_2009\/gallery_enlarged\/gallery_enlarged-calexico-pete-bratach-3.jpg"]},
{"link_id":266931315214,"owner":563683308,
"owner_comment":"It's like a script from a bad movie. I can't wait for the next \"get yer gub'mint hands off my [INSERT FEDERAL PROGRAM NAME HERE].\"",
"created_time":1251748026,"title":"Think Progress \u00bb Local official to Bachmann: \u2018I\u2019ll be danged if I am going to give up my Social Secu",
"summary":"In Lake Elmo, Minnesota yesterday, Rep. Michele Bachmann held a \u201craucous\u201d town hall meeting to discuss health care reform that was filled with \u201cdeafening cheers and a few jeers.\u201d ...",
"url":"http:\/\/thinkprogress.org\/2009\/08\/28\/bachmann-constituent-social-security\/",
"image_urls":["http:\/\/thinkprogress.org\/wp-content\/uploads\/2009\/08\/bachman.gif"]}]
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 link_id FROM link WHERE owner=loggedInUid
Error Codes
| Code | Description | |
| 1 | An unknown error occurred. Please resubmit the request. | |
|---|---|---|
| 2 | The service is not available at this time. | |
| 4 | The application has reached the maximum number of requests allowed. More requests are allowed once the time window has completed. | |
| 5 | The request came from a remote address not allowed by this application. | |
| 101 | The API key submitted is not associated with any known application. | |
| 102 | The session key was improperly submitted or has reached its timeout. Direct the user to log in again to obtain another key. | |
| 103 | The submitted call_id was not greater than the previous call_id for this session. | |
| 282 | Managing shared items requires the extended permission share_item. |
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).
