[英]$facebook->api callback function?
anyone know of a callback function I can call after I have done a FB api call using the PHP SDK? 有人知道我使用PHP SDK完成FB api调用后可以调用的回调函数吗?
If not, is there some way I can build one into the SDK? 如果没有,是否可以通过某种方法将其构建到SDK中?
Thanx in advance! 提前感谢!
This isn't necessary, as all calls to the Facebook Graph API via the PHP SDK are synchronous . 这是没有必要的,因为通过PHP SDK对Facebook Graph API的所有调用都是sync 。 Therefore you can call any function directly after the call to the API, consider this example: 因此,可以在调用API之后直接调用任何函数,请考虑以下示例:
<?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. 另外,PHP-SDK是开源的,因此您也可以将其派生,实现功能并通过更改将请求提交给Github。 You can find the Source at https://github.com/facebook/php-sdk . 您可以在https://github.com/facebook/php-sdk上找到源。
Put the API call in a try/catch statement... 将API调用放入try / catch语句中...
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!";
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.