Reputation: 6635
anyone know of a callback function I can call after I have done a FB api call using the PHP SDK?
If not, is there some way I can build one into the SDK?
Thanx in advance!
Upvotes: 1
Views: 3627
Reputation: 593
This isn't necessary, as all calls to the Facebook Graph API via the PHP SDK are synchronous. Therefore you can call any function directly after the call to the API, consider this example:
<?php
try {
$result = $facebook->api("/me");
do_something($result);
} catch (Exception $e) {
// Log Error
}
Also the PHP-SDK is Open Source, so you could also fork it, implement your feature and file a Pull Request on Github with your changes. You can find the Source at https://github.com/facebook/php-sdk.
Upvotes: 5
Reputation: 21531
Put the API call in a try/catch statement...
try {
$facebook->api(array(
'query' => $query,
'method' => 'fql.query'
));
} catch (FacebookApiException $e) {
echo 'An error occured!';
}
// Assume it has worked as the exception has not been caught
echo "It worked!";
Upvotes: 2