使用 Facebook Graph API & 进行批量调用PHP

时间:2023-01-18
本文介绍了使用 Facebook Graph API & 进行批量调用PHP的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用 Facebook 提供的 PHP 库的 2.1.2 版,针对 Graph API 设计我的第一个应用程序.试图最大限度地提高性能等开箱即用,并希望将几个调用一起批处理为一个调用,但在文档中找不到任何内容......我确定我一定遗漏了一些简单的东西,但我很难过.

我想将这些调用(只是一个示例)转换为单个批处理调用:

$me = $facebook->api('/me', $params);$groups = $facebook->api('/me/groups', $params);

解决方案

Facebook 推荐使用 FQL 为此;http://developers.facebook.com/docs/guides/performance通过在(嵌套)查询中组合您的请求.

他们自己的例子:

$friends_locations = $facebook->api_client->fql_query('SELECT hometown_location from user where uid in ' .'(SELECT uid2 fromfriend where uid1=' . $user_id . ')');

如果您的请求不相互依赖,您可以使用 fql.multiquery

Designing my first app against the Graph API, using version 2.1.2 of the Facebook supplied PHP library. Trying to maximize performance, etc out of the box and want to batch a few calls together into one call, but can't find anything in the documentation... I am sure I must be missing something simple, but am stumped.

I'd like to turn these calls (just an example) into a single batched call:

$me     = $facebook->api('/me', $params);
$groups = $facebook->api('/me/groups', $params);

解决方案

Facebook recommends using FQL for this; http://developers.facebook.com/docs/guides/performance by combining your requests in a (nested) query.

Their own example:

$friends_locations = $facebook->api_client->fql_query(
    'SELECT hometown_location from user where uid in ' .
    '(SELECT uid2 from friend where uid1=' . $user_id . ')');

If your requests aren't dependant on eachother you can use fql.multiquery

这篇关于使用 Facebook Graph API & 进行批量调用PHP的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

上一篇:'找不到类'FacebookFacebook'Facebook SDK 错误 下一篇:Facebook 图形 API 仅返回某些网站的名称和 ID

相关文章

最新文章