Let's take a simple FQL
query to get all links shared by a user's friends since yesterday for example:
SELECT link_id, title, url, owner, created_time
FROM link
WHERE
created_time > strtotime('yesterday') AND
owner IN (
SELECT uid2 FROM friend WHERE uid1 = me()
)
LIMIT 100
If a user has 50 friends, this will execute perfectly. But if a user has hundreds of friends, more often than not Facebook returns an error.
Options:
- Limit the friend select query to 50 -- Sure, that will work, but it will show the same friends every time. Unless you want an Ivy League-only feed, this isn't very helpful.
- Batch Queries -- Create a batch of queries using offsets and limit each to 50. Unfortunately there's no improvement here either.
- Loop It -- So far this is the best I've found. Loop through the same queries you built for a batch query, but do it one at a time with multiple api fql query calls. But even this is hit and miss.
How can I query Facebook appropriately to ensure successful results?
Notes:
- I'm using the latest Facebook php sdk, 3.1.1
- I've also tried extending the default options for curl timeouts in the base_facebook.php
Common Errors associated with Timeout:
1.
Fatal error: Uncaught Exception: 1: An unknown error occurred thrown in /..../facebook/php-sdk/src/base_facebook.php on line 708
line 708 is an exception error:
// results are returned, errors are thrown
if (is_array($result) && isset($result['error_code'])) {
throw new FacebookApiException($result);
}
2.
Fatal error: Uncaught CurlException: 52: SSL read: error:00000000:lib(0):func(0):reason(0), errno 104 thrown in /..../facebook/php-sdk/src/base_facebook.php on line 814