Facebook 应用程序用户列表

发布于 2024-10-31 11:30:08 字数 1632 浏览 2 评论 0原文

我对 Facebook API 相当陌生。我想获取也安装了我的应用程序的朋友的列表。 (这个想法是你可以和他们开始游戏)。

这给出了我的朋友列表:

FB.api('/me/friends', ...

这给出了我的应用程序信息:

FB.api('/myappid', ...

我想要的是“我的朋友也安装了这个应用程序”

我想可能是这样的:

FB.api('/myappid/accounts', ...

我希望这至少会给我我的开发人员、管理员或测试人员,但没有这样的运气。 http://developers.facebook.com/docs/test_users/ http://developers.facebook.com/docs/ApplicationSecurity/

我的感觉也许是我必须使用 FQL 来信任这样的查询:

(psuedocode)
SELECT
FROM my_friends
WHERE uid IN (
    SELECT uid
    FROM app_users
    WHERE appid = myappid
)

任何建议将不胜感激。

注意,我看过这个帖子: FaceBook 应用程序:检索我的应用程序用户的 ID 列表< /a>

我保留了属于我网站的 Facebook 用户 ID 的本地列表,实际上我可以通过执行以下操作来实现我的目标,但我确信一定有更好的方法:

$facebookFriendIds = array();
$friends = $this->facebook->api('/me/friends');
foreach ($friends['data'] as $friend) {
    $facebookFriendIds[] = $friend['id'];
}

$this->friends = Doctrine_Core::getTable('User')->createQuery()
    ->whereIn('fb_user_id', $facebookFriendIds)
    ->execute();

I am fairly new to the Facebook APIs. I want to get a list of my friends who have also installed my app. (The idea being you can then start a game with them).

This gives a list of my friends:

FB.api('/me/friends', ...

This gives my app info:

FB.api('/myappid', ...

What I want is "my friends who also have this app installed"

I thought it might be this:

FB.api('/myappid/accounts', ...

I was hoping that would at least give me my Developers, Administrators or Testers, but no such luck.
http://developers.facebook.com/docs/test_users/
http://developers.facebook.com/docs/ApplicationSecurity/

My feeling is perhaps I have to use FQL to construst a query that says something like

(psuedocode)
SELECT
FROM my_friends
WHERE uid IN (
    SELECT uid
    FROM app_users
    WHERE appid = myappid
)

Any advice would be greatly appreciated.

Note, I have seen this post:
FaceBook app: retrieve list of ids of my application's users

I am keeping a local list of Facebook User's IDs that belong to my site, and I am actually able to achieve my goal by doing the following, but I am sure there must be a better way:

$facebookFriendIds = array();
$friends = $this->facebook->api('/me/friends');
foreach ($friends['data'] as $friend) {
    $facebookFriendIds[] = $friend['id'];
}

$this->friends = Doctrine_Core::getTable('User')->createQuery()
    ->whereIn('fb_user_id', $facebookFriendIds)
    ->execute();

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

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

发布评论

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

评论(2

黯淡〆 2024-11-07 11:30:08

这是我相信的 FQL 查询

$facebook->api(array('method' => 'fql.query', 'query' => "SELECT uid FROM user WHERE is_app_user = '1' AND uid IN (SELECT uid2 FROMfriend WHERE uid1 = '" . $user_id . "');"));

(我使用 java 和 JS API,因此语法可能不完全正确)

用户和朋友的文档查询在这里:

http://developers.facebook.com/docs/reference/fql/用户/

http://developers.facebook.com/docs/reference/ fql/朋友/

This is I believe the FQL query

$facebook->api(array('method' => 'fql.query', 'query' => "SELECT uid FROM user WHERE is_app_user = '1' AND uid IN (SELECT uid2 FROM friend WHERE uid1 = '" . $user_id . "');"));

(I use java and JS APIs so the syntax may not be exactly correct)

The documentation for the user and friend queries are here:

http://developers.facebook.com/docs/reference/fql/user/

http://developers.facebook.com/docs/reference/fql/friend/

北恋 2024-11-07 11:30:08

在JS中使用这个查询

function getAppFriends()
{

    var fql = "SELECT uid, name, pic_square, is_app_user 
               FROM user 
               WHERE uid IN (SELECT uid2 FROM friend WHERE uid1 = me()) 
               OR uid IN(SELECT uid1 FROM friend WHERE uid2=me()) 
               ORDER BY  name";

    var query = FB.Data.query(fql);

    query.wait(function(responseFromFb){

       if(responseFromFb!=null){

           // Read the responseFromFb and check for 
           // is_app_user = true and list them out the way 
           // you want to.

       }

    });// anonymus function closes here
} //function ends here

Use this query in JS

function getAppFriends()
{

    var fql = "SELECT uid, name, pic_square, is_app_user 
               FROM user 
               WHERE uid IN (SELECT uid2 FROM friend WHERE uid1 = me()) 
               OR uid IN(SELECT uid1 FROM friend WHERE uid2=me()) 
               ORDER BY  name";

    var query = FB.Data.query(fql);

    query.wait(function(responseFromFb){

       if(responseFromFb!=null){

           // Read the responseFromFb and check for 
           // is_app_user = true and list them out the way 
           // you want to.

       }

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