使用 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的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

相关文档推荐

DeepL的翻译效果还是很强大的,如果我们要用php实现DeepL翻译调用,该怎么办呢?以下是代码示例,希望能够帮到需要的朋友。 在这里需要注意,这个DeepL的账户和api申请比较难,不支持中国大陆申请,需要拥有香港或者海外信用卡才行,没账号的话,目前某宝可以
PHP通过phpspreadsheet导入Excel日期,导入系统后,全部变为了4开头的几位数字,这是为什么呢?原因很简单,将Excel的时间设置问文本,我们就能看到该日期本来的数值,上图对应的数值为: 要怎么解决呢?进行数据转换就行,这里可以封装方法,或者用第三方的
mediatemple - can#39;t send email using codeigniter(mediatemple - 无法使用 codeigniter 发送电子邮件)
Laravel Gmail Configuration Error(Laravel Gmail 配置错误)
Problem with using PHPMailer for SMTP(将 PHPMailer 用于 SMTP 的问题)
Issue on how to setup SMTP using PHPMailer in GoDaddy server(关于如何在 GoDaddy 服务器中使用 PHPMailer 设置 SMTP 的问题)