You can use the FacebookApiException Class to catch the exceptions.
Example-
try {
$sfqlResult = $facebook -> api($sparam);
} catch(FacebookApiException $e) {
$e_type = $e->getType();
$result = $e->getResult();
error_log('Got an ' . $e_type . ' while posting');
error_log(json_encode($result));
}
But according to me, there's token related issue, the exception will not be thrown but the error result will be returned in $sfqlResult
; and you can check the object $sfqlResult->error;
if(!isset($sfqlResult['error']))
{
// no error
}
else
{
echo "Facebook error: ".$sfqlResult['error']->message;
}