无法访问Facebook登录? [英] Unable to access facebook login?

查看:692
本文介绍了无法访问Facebook登录?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用Facebook的官方Android SDK,我在Facebook上的应用程序的管理员。

我读到默认情况下,应用程序在沙盒模式,没有人,除了管理员和开发人员可以访问它。我使用它在我的Andr​​oid应用程序添加Facebook登录设施。不过,我加了我的朋友,谁是我为开发人员在开发应用程序,但他们不能通过Facebook登录与应用程序帐户凭据。我禁用了应用程序的沙盒模式从Facebook的应用程序设置,还是他们不能访问登录功能。一旦点击Facebook的登录按钮,他们将被重定向到相同的活性,而不会发生任何事情,而在我的情况下,我顺利登录和应用程序正常进行。

是否有任何额外的设置,我需要以使其公开办?

感谢:)


解决方案

  Session.openActiveSession(这一点,真正的,新的Session.StatusCallback(){            //回调时,会话状态变化
            @覆盖
            公共无效呼叫(会话的会话,SessionState会的状态,
                    例外的例外){
                如果(session.isOpened()){
                    //使请求/我API                    清单<串GT;权限= session.getPermissions();
                    如果(!isSubsetOf(权限,权限)){
                        pendingPublishReauthorization =真;
                        Session.NewPermissionsRequest newPermissionsRequest =新Session.NewPermissionsRequest(
                                RegisterActivity.this,权限);
                        session.requestNewReadPermissions(newPermissionsRequest);
                        返回;
                    }
                    Request.executeMeRequestAsync(会话,
                            新Request.GraphUserCallback(){                        //后图形API响应回调
                        //用户对象
                        @覆盖
                        公共无效onCompleted(GraphUser用户,
                                响应响应){
                            如果(用户== NULL){
                                Toast.makeText(
                                        RegisterActivity.this
                                        .getApplicationContext(),
                                        Facebook的错误,
                                        Toast.LENGTH_LONG).show();                            }其他{
                                Toast.makeText(
                                        RegisterActivity.this
                                        .getApplicationContext(),
                                        user.getName()
                                        +登录成功。
                                        Toast.LENGTH_LONG).show();
                                GraphUser ABC =用户;                                ID = user.getId();
                                名称= user.getName();
                                性别= user.getProperty(性别)
                                        的ToString();
                                editname.setText(名);
                                username.setText(user.getUsername());
                                乔JSONObject的用户=
                                        .getInnerJSONObject();
                                Log.d(详细信息,jo.toString());
                                尝试{
                                    emailid.setText(用户
                                            .getProperty(电子邮件)
                                            的ToString());
                                }赶上(例外E1){
                                    // TODO自动生成捕
                                    //块
                                    e1.printStackTrace();
                                }                                尝试{
                                    位置= user.getLocation()
                                            .getProperty(名称)
                                            的ToString();
                                }赶上(例外五){                                    e.printStackTrace();
                                }                            }                            返回;
                        }                    });                }
            }
        });

的onActivityResult 方法

  @覆盖
公共无效的onActivityResult(INT申请code,INT结果code,意图数据){
    super.onActivityResult(要求code,结果code,数据);
    Session.getActiveSession()的onActivityResult(这一点,要求code,
            结果code,数据);
}

isSubsetoff()方法

 私人布尔isSubsetOf(收集和LT;弦乐>的子集,
        收集和LT;弦乐>超){
    对于(字符串字符串:子集){
        如果(!superset.contains(字符串)){
            返回false;
        }
    }
    返回true;
}

权限根据自己的需要

 私有静态最终名单<串GT; PERMISSIONS = Arrays.asList(电子邮件
        user_about_me,USER_LOCATION,user_checkins);

I am using Facebook's official Android SDK, and I am administrator of an app on Facebook.

I read that by default, the app is in sandbox mode and no one except administrator and developers can access it. I am using it to add Facebook login facility in my android app. However, I added my friends, who are developing the app with me as developers, but they cant log in via Facebook with their account credentials from the app. I disabled the sandbox mode for app from Facebook's app settings, still they cant access the login facility. Once they click on Facebook login button, they are redirected to the same activity without anything happening, whereas in my case, I login successfully and the app proceeds normally.

Are there any extra settings I need to do in order to make it public?

Thanks :)

解决方案

       Session.openActiveSession(this, true, new Session.StatusCallback() {

            // callback when session changes state
            @Override
            public void call(Session session, SessionState state,
                    Exception exception) {
                if (session.isOpened()) {
                    // make request to the /me API

                    List<String> permissions = session.getPermissions();
                    if (!isSubsetOf(PERMISSIONS, permissions)) {
                        pendingPublishReauthorization = true;
                        Session.NewPermissionsRequest newPermissionsRequest = new Session.NewPermissionsRequest(
                                RegisterActivity.this, PERMISSIONS);
                        session.requestNewReadPermissions(newPermissionsRequest);
                        return;
                    }
                    Request.executeMeRequestAsync(session,
                            new Request.GraphUserCallback() {

                        // callback after Graph API response with
                        // user object
                        @Override
                        public void onCompleted(GraphUser user,
                                Response response) {
                            if (user == null) {
                                Toast.makeText(
                                        RegisterActivity.this
                                        .getApplicationContext(),
                                        "Facebook Error",
                                        Toast.LENGTH_LONG).show();

                            } else {
                                Toast.makeText(
                                        RegisterActivity.this
                                        .getApplicationContext(),
                                        user.getName()
                                        + " Logged in Successfully.",
                                        Toast.LENGTH_LONG).show();
                                GraphUser abc = user;

                                id = user.getId();
                                name = user.getName();
                                gender = user.getProperty("gender")
                                        .toString();
                                editname.setText(name);
                                username.setText(user.getUsername());
                                JSONObject jo = user
                                        .getInnerJSONObject();
                                Log.d("Details", jo.toString());
                                try {
                                    emailid.setText(user
                                            .getProperty("email")
                                            .toString());
                                } catch (Exception e1) {
                                    // TODO Auto-generated catch
                                    // block
                                    e1.printStackTrace();
                                }

                                try {
                                    location = user.getLocation()
                                            .getProperty("name")
                                            .toString();
                                } catch (Exception e) {

                                    e.printStackTrace();
                                }



                            }

                            return;
                        }

                    });

                }
            }
        });

Put onActivityResult Method

@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);
    Session.getActiveSession().onActivityResult(this, requestCode,
            resultCode, data);
}

isSubsetoff() Method

   private boolean isSubsetOf(Collection<String> subset,
        Collection<String> superset) {
    for (String string : subset) {
        if (!superset.contains(string)) {
            return false;
        }
    }
    return true;
}

and the permissions as per your need

  private static final List<String> PERMISSIONS = Arrays.asList("email",
        "user_about_me", "user_location", "user_checkins");

这篇关于无法访问Facebook登录?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆