如何使用 Facebook Graph API 执行 FQL 查询

发布于 2024-08-30 09:52:01 字数 242 浏览 3 评论 0原文

我正在寻找一种使用新的 Open Graph API 执行 FQL(facebook 查询语言)查询的方法,但没有成功。

有谁知道我该怎么做?

通过这个优秀的例子在这里找到了答案: http://code.google.com/p/facebook-cpp-graph-接口/

I'm looking without any success for a way to execute a FQL(facebook query language) query with the new Open Graph API.

Does anyone know how I can do this?

Found the answer here with this excellent example:
http://code.google.com/p/facebook-cpp-graph-api/

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

这个俗人 2024-09-06 09:52:02

这是在短时间内执行多个 fql 查询的另一种方法。

//$current_user=facebook id

 $query1="SELECT uid, name FROM user WHERE is_app_user=1 AND uid IN (SELECT uid2 FROM friend WHERE uid1 = $current_user)";
 $query2="SELECT uid, name, work_history FROM user WHERE uid IN (SELECT uid2 FROM friend WHERE uid1 = $current_user )";
 $query3="SELECT uid, name, work, education FROM user WHERE uid = $current_user";
 $queries = array(
           array('method'=>'GET', 'relative_url'=>'method/fql.query?query='.str_replace(' ','+',$query1)),
           array('method'=>'GET', 'relative_url'=>'method/fql.query?query='.str_replace(' ','+',$query2)),
           array('method'=>'GET', 'relative_url'=>'method/fql.query?query='.str_replace(' ','+',$query3))
            );

            $objs = $facebook->api('/?batch='.json_encode($queries), 'POST');

$objs 获取三个查询的整个结果的 json 数组。

而且它节省了很多时间。这 3 个查询总共需要 9 秒。使用多重查询需要 7 秒。对于批量请求,需要 3.6 秒。

This is another way to execute multiple fql queries in short span.

//$current_user=facebook id

 $query1="SELECT uid, name FROM user WHERE is_app_user=1 AND uid IN (SELECT uid2 FROM friend WHERE uid1 = $current_user)";
 $query2="SELECT uid, name, work_history FROM user WHERE uid IN (SELECT uid2 FROM friend WHERE uid1 = $current_user )";
 $query3="SELECT uid, name, work, education FROM user WHERE uid = $current_user";
 $queries = array(
           array('method'=>'GET', 'relative_url'=>'method/fql.query?query='.str_replace(' ','+',$query1)),
           array('method'=>'GET', 'relative_url'=>'method/fql.query?query='.str_replace(' ','+',$query2)),
           array('method'=>'GET', 'relative_url'=>'method/fql.query?query='.str_replace(' ','+',$query3))
            );

            $objs = $facebook->api('/?batch='.json_encode($queries), 'POST');

$objs gets json array of whole result of thre queries.

And it is saving time a lot. This 3 queries individually takes total 9 seconds. With multiquery it takes 7 seconds. And with batch request it takes 3.6 seconds.

鱼忆七猫命九 2024-09-06 09:52:02

FQL with PHP 这里我展示了如何使用 FQL。如果您仔细查看当前的 facebook api 文档,就会发现非常简单。有时最好不要阅读有关 facebook api 问题的文章并直接查看文档。

FQL with PHP here I show how to use FQL. It is very simple if you take a careful look at the current facebook api documentation. Sometimes it is better to not read articles about facebook api issues and look straight at the documentation.

满栀 2024-09-06 09:52:01

以下是如何使用 Graph API 和 JavaScript 执行 FQL 查询的示例。

FB.api(
        {
            method: 'fql.query',
            query: 'SELECT uid, first_name, last_name FROM user WHERE uid = ' + someUid
        },
        function(data) {
            //    do something with the response
        }
);

这假设您已经根据 Facebook 指南设置了页面,如下所示 - http://developers.facebook.com/docs/reference/javascript/

Here's an example of how to do a FQL query using the Graph API and JavaScript

FB.api(
        {
            method: 'fql.query',
            query: 'SELECT uid, first_name, last_name FROM user WHERE uid = ' + someUid
        },
        function(data) {
            //    do something with the response
        }
);

This assumes you've already setup your page according to the Facebook guidelines as shown here - http://developers.facebook.com/docs/reference/javascript/

随梦而飞# 2024-09-06 09:52:01

PHP解决方案:

$data = $facebook->api(array('method' => 'fql.query', 'query' => 'SELECT columns FROM table...' ));

PHP Solution:

$data = $facebook->api(array('method' => 'fql.query', 'query' => 'SELECT columns FROM table...' ));
吃颗糖壮壮胆 2024-09-06 09:52:01

使用 Javascript SDK,您可以通过以下方式完成此操作:

 FB.api('fql', { q: 'query here' }, function (response)
{
 //Logic here
};

无需旧版 REST API。我看到这方面有很多混乱,Facebook 也没有说得很清楚。

Using the Javascript SDK, you can accomplish this using the following:

 FB.api('fql', { q: 'query here' }, function (response)
{
 //Logic here
};

No legacy REST API required. I see a lot of confusion on this and Facebook hasn't made it very clear.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文