1

I'm working on a simple facebook application where I'm storing:

Facebook friends ID

Table structure:

Table name: facebook_mapping Values:

app_id                fb_id
1               100003996070108
2               100003960002436
3               100003955972927
4               100003955972924

using fql query:

SELECT uid2 FROM friend WHERE uid1=FACEBOOK_USER_ID

This works well for friends less than 200. But if a user has more than 200 friends, when I run the application page for the first time, it times out always. I think it takes more than 30 seconds and my server has a constraint that it would timeout after 30 seconds.

I'm using PHP & MySQL. One solution I think is:

1) First only take 20 friends of that user and add it in database 2) Run a background process to gather other friends

Please help me to setup a background process to gather friends or some other method to do this.

Thanks.

4

2 回答 2

3

If it’s your PHP script timing out on inserting the data (and not the API request itself) – then how exactly are you adding the data into your table?

Are you firing 200+ individual INSERT statements at your database in a PHP loop or something?

If that’s the case, try putting all the data (or larger chunks of it) into a multiple row INSERT statement, in the form of

INSERT INTO table (column1, column2)
  VALUES (1, '100003996070108'), (2, '100003960002436'), (…)

That should help prevent PHP script timeouts, because you don’t have to make so many individual queries to your database.

于 2012-06-24T12:08:01.870 回答
2

This doesn't appear to be an issue with the Facebook API, just the timeout that you configured on our server. The background thread idea is a good one.

于 2012-06-23T22:33:34.977 回答