android - 如何将 Facebook api 查询的结果与我自己的 MySQL 表连接起来

标签 android mysql facebook-graph-api facebook-fql

将 Facebook api 查询结果与我自己的 MySQL 数据库相结合的最佳方式是什么? 我正在尝试显示我的 friend 正在关注的博客列表。 我正在使用 android Facebook sdk 3.0。以下是我获取好友列表的方法,效果很好。

Session session  = Session.getActiveSession();

    if(session.isOpened())
    {
        Request.executeMyFriendsRequestAsync(session, new Request.GraphUserListCallback() 
        {

            @Override
            public void onCompleted(List<GraphUser> users, Response response) 
            {
                updateUI(users);
            }


        });
    }

我需要将这些结果与我自己的数据库结合起来,以便显示我的 friend 正在关注的博客列表。我有一个这样的数据库表:

Table name: blog_followers
Columns: id, user_id, blog_id

结果应该是这样的:您的 7 个 friend 正在关注“如何烧烤食物”。

我还有一个用户表:

Table name: users
Columns: id, email, facebook_id

我只需要使用我 friend 的 facebook id、我的用户表和我的 blog_followers 表进行加入。 在 Android 上执行此操作的最佳方法是什么?

最佳答案

  1. 使用 SQL IN() 过滤您的表运算符,如Compare Facebook array of friendslist to MySQL table所示;或者

  2. 将 Facebook 结果集推送到临时表中,然后照常将其连接到 RDBMS 中的现有数据。

    根据 CREATE TABLE Syntax 记录:

    Temporary Tables

    You can use the TEMPORARY keyword when creating a table. A TEMPORARY table is visible only to the current connection, and is dropped automatically when the connection is closed. This means that two different connections can use the same temporary table name without conflicting with each other or with an existing non-TEMPORARY table of the same name. (The existing table is hidden until the temporary table is dropped.) To create temporary tables, you must have the CREATE TEMPORARY TABLES privilege.

关于android - 如何将 Facebook api 查询的结果与我自己的 MySQL 表连接起来,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17351697/

相关文章:

android - Facebook 申请请求

javascript - Cordova InAppBrowser 和 FaceBook 应用程序事件记录器

android - Kotlin:应用程序不询问用户权限

android - 是否可以从 ContentProvider bulkInsert 获取最后的 "N"ID?

php - 搜索多个表格 - 如果未填写输入,则保留表格

php - 更改数据库记录排序顺序以使用 PHP 在其他记录之间移动记录位置

javascript - 状态栏下方的 Nativescript 操作栏

android - 错误的状态类,期望查看状态但接收到类 android.widget.CompoundButton$SavedState

mysql - #1064 - 您的 SQL 语法有误;查看与您的 MySQL 服务器版本对应的手册

javascript - 如何在回调函数之外使用 FB.api(JS SDK) 响应?