For those of you wondering how to perform Facebook multi query request through Facebook official PHP SDK, here is a quick implementation:
-First create your queries as JSON object (this could be either done through creating an array and then calling json_encode function of php json plugin or you can directly form it as I did in here). Here we want to retrieve the names of family members of a particular user.
$queries = '{
"uids":"select uid from family where profile_id=**********",
"names":"select name from user where uid in (select uid from #uids)"
}';
-Second, you need to create the parameter array as follows:
$param = array(
'method' => 'fql.multiquery',
'queries' => $queries,
'access_token' => $access_token //here you need your own access token
);
-third, call the api function:
$userdata = $facebook->api($param);
-fourth, you are done, no need to do anything else.
It is that easy. This would prevent you from issuing two separate queries.
Monday, June 20, 2011
Friday, June 17, 2011
Background Jobs In iPhone
There is two subtopic for this issue: first is job could be executed while the application is in a running mode or job could be executed when the application is suspended. Both two scenarios are possible in iPhone, however the later is really restricted.
If you want to run a job during the suspended phase, where the application is closed and stays in the background, there are a few operations that iPhone allows developer to do. These operations could be a VOIP (like skype does), audi (like iPod does) or a location tracking. Other than these there is no operation that developers can do in iPhone. Also note that mimicking your application as if it is using VOIP would cause your application to be rejected from app store, so don't even try to get around things!.
Another issue is to run job in the background while the application is running. This is done through threading in the iPhone. NSThread is the Objective-C class for this. Go exploit it!. But careful about memory management. Here is a few tips:
- Allocate and deallocate your auto release pool. Otherwise you'll end up with memory leaks.
- Don't play with UIKit unless you are in a main thread. This will cause some undefined behavior.
Addition to the last scenario might be the possibility of running the job periodically. This can be done by firing and NSTimer and adding this to the current running loop.
If you want to run a job during the suspended phase, where the application is closed and stays in the background, there are a few operations that iPhone allows developer to do. These operations could be a VOIP (like skype does), audi (like iPod does) or a location tracking. Other than these there is no operation that developers can do in iPhone. Also note that mimicking your application as if it is using VOIP would cause your application to be rejected from app store, so don't even try to get around things!.
Another issue is to run job in the background while the application is running. This is done through threading in the iPhone. NSThread is the Objective-C class for this. Go exploit it!. But careful about memory management. Here is a few tips:
- Allocate and deallocate your auto release pool. Otherwise you'll end up with memory leaks.
- Don't play with UIKit unless you are in a main thread. This will cause some undefined behavior.
Addition to the last scenario might be the possibility of running the job periodically. This can be done by firing and NSTimer and adding this to the current running loop.
Subscribe to:
Posts (Atom)