Page 1 of 1
Asynchronous php
Posted: Mon May 04, 2009 10:34 am
by TheStoryTeller
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?
Re: Asynchronous php
Posted: Mon May 04, 2009 10:46 am
by novice4eva
I bet they were talking about "ajax", make separate CALCULATION request for each friend and when the output is ready, display it.
Re: Asynchronous php
Posted: Mon May 04, 2009 2:26 pm
by TheStoryTeller
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 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?
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
Posted: Mon May 04, 2009 3:18 pm
by infolock
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.
Re: Asynchronous php
Posted: Mon May 04, 2009 4:13 pm
by TheStoryTeller
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.
Thanks, I'll check this Ajax situation.
Re: Asynchronous php
Posted: Sat May 30, 2009 12:25 pm
by TheStoryTeller
can anyone help me with an efficient way of background calculation?
Re: Asynchronous php
Posted: Sat May 30, 2009 4:29 pm
by jaoudestudios
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.