【问题标题】:Allow app access for only specific FB users仅允许特定 FB 用户访问应用程序
【发布时间】:2012-12-01 03:02:22
【问题描述】:

最终,我想要一个可以访问我的应用程序管理部分的用户 ID 白名单。我希望使用 Facebook 身份验证和相关的用户个人资料 ID 来处理这个问题。

目前,我有:

if (session == Session.getActiveSession()) {
   if (user != null) {
       // Set the id for the ProfilePictureView
       // view that in turn displays the profile picture
       profilePictureView. setProfileId(user.getId());

       // Set the Textview's text to the user's name
       userNameView.setText(user.getName());

       // Set the Textview's text from user's id
       userId.setText(user.getId());

       String approved = "553660552";

       if(user.getId() != approved){
          //553660552
          userId.setText(user.getId());
        } else {
          userId.setText("Goodie");
        }

   }   
} 

user.getId() 返回 553660552,但比较失败。 (当批准是不同的值时,它也会失败)。

总而言之,user.getId() 返回 553660552(在这种情况下)。我需要能够对白名单进行匹配比较。是的,任何设置为“553660552”的String 都不匹配

感谢所有帮助。

【问题讨论】:

    标签: java android facebook facebook-graph-api sdk


    【解决方案1】:

    使用字符串的 .equals() 方法进行比较,即,

    if (approved.equals(user.getId())) 
    

    【讨论】:

    • 谢谢。我做了一些搜索来寻找这个答案,但它显然是一个基本的 Java 问题,与 Android 或 Facebook SDK 无关。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-02-03
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-08-16
    • 1970-01-01
    相关资源
    最近更新 更多