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

Batch calls with Facebook Graph API amp; PHP(使用 Facebook Graph API amp; 进行批量调用PHP)
本文介绍了使用 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的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

本站部分内容来源互联网,如果有图片或者内容侵犯您的权益请联系我们删除!

相关文档推荐

Facebook Login with Strict Mode for Redirect URIs(使用重定向 URI 的严格模式登录 Facebook)
How to retrieve post ID for a post i#39;ve just made via the Facebook API(如何检索我刚刚通过 Facebook API 发布的帖子的帖子 ID)
Facebook PHP SDK logout(Facebook PHP SDK 注销)
Facebook SDK and Graph API Comment Deleting Error(Facebook SDK 和 Graph API 评论删除错误)
PHP amp; Facebook: facebook-debug a URL using CURL and Facebook debugger(PHP amp;Facebook: facebook-debug a URL using CURL and Facebook debugger)
Can#39;t delete photo via Facebook API?(无法通过 Facebook API 删除照片?)