Hello,
I have a problem (obviously).
I am writing a simple Facebook application which gives the user a table with basic statistics of his friends. nothing fancy.
Some users have a lot of friends. When I tested the application with some of my friends-rich friends account - I realized that since the calculation is too long, facebook is giving a standrad error message and stops.
For other friends it works fine.
This is a PHP forum so i'll cut to the chase:
In the Facebook developer forum they advised me to make my code asynchronous. that is, send some page to the user and continue the process behind the scene.
I haven't the slightest idea how to approach that. any suggestion?
Asynchronous php
Moderator: General Moderators
- novice4eva
- Forum Contributor
- Posts: 327
- Joined: Thu Mar 29, 2007 3:48 am
- Location: Nepal
Re: Asynchronous php
I bet they were talking about "ajax", make separate CALCULATION request for each friend and when the output is ready, display it.
-
TheStoryTeller
- Forum Newbie
- Posts: 15
- Joined: Fri May 01, 2009 10:13 am
Re: Asynchronous php
I still have trouble understanding it. my native language is Java or C++. I'm very familiar with the consept of "threads of execution" is there a way of doing something like that in PHP? is that what you mean?novice4eva wrote:I bet they were talking about "ajax", make separate CALCULATION request for each friend and when the output is ready, display it.
I don't expect anyone to give me a working code or anything, I'm very willing to learn - I just need someone to point me in the right direction...
Re: Asynchronous php
PHP does not support threading, although there is a nice article on faking it.
When they tell you asynchronous though, they mean to use ajax (Asynchronous Javascript And XML).
Since you're application or facebook is bombing at x %, they are suggestion you do a step by step process kind of like pagination. Grab x amount of friends (25 for examle) and display them. After displaying, use an AJAX call to grab the next x, and repeat until all are in your hands.
There are MANY tutorials on Ajax, and ajax with PHP.
Hope this helps.
When they tell you asynchronous though, they mean to use ajax (Asynchronous Javascript And XML).
Since you're application or facebook is bombing at x %, they are suggestion you do a step by step process kind of like pagination. Grab x amount of friends (25 for examle) and display them. After displaying, use an AJAX call to grab the next x, and repeat until all are in your hands.
There are MANY tutorials on Ajax, and ajax with PHP.
Hope this helps.
-
TheStoryTeller
- Forum Newbie
- Posts: 15
- Joined: Fri May 01, 2009 10:13 am
Re: Asynchronous php
Thanks, I'll check this Ajax situation.infolock wrote:PHP does not support threading, although there is a nice article on faking it.
When they tell you asynchronous though, they mean to use ajax (Asynchronous Javascript And XML).
Since you're application or facebook is bombing at x %, they are suggestion you do a step by step process kind of like pagination. Grab x amount of friends (25 for examle) and display them. After displaying, use an AJAX call to grab the next x, and repeat until all are in your hands.
There are MANY tutorials on Ajax, and ajax with PHP.
Hope this helps.
-
TheStoryTeller
- Forum Newbie
- Posts: 15
- Joined: Fri May 01, 2009 10:13 am
Re: Asynchronous php
can anyone help me with an efficient way of background calculation?
- jaoudestudios
- DevNet Resident
- Posts: 1483
- Joined: Wed Jun 18, 2008 8:32 am
- Location: Surrey
Re: Asynchronous php
I dont know if facebook will let you do it, but an easy way to achieve ajax is to use the javascript library jQuery. You'll be putting together ajax applications in minutes.