12

我在我的应用程序中使用 Parse SDK ( https://github.com/ParsePlatform/Parse-SDK-Android )。

我的应用程序还使用 Facebook Utils 来提供 Facebook 登录体验 ( https://github.com/ParsePlatform/ParseFacebookUtils-Android )

最近我收到了 Facebook 开发人员关于我的一个应用程序的以下消息:“xxx 最近一直在对 Graph API v2.0 进行 API 调用,这将在 8 月 8 日星期一达到 2 年弃用窗口的结束, 2016. 请将所有调用迁移到 v2.1 或更高版本,以避免潜在的损坏体验。”

我该如何解决这个问题?

这是我在依赖部分中的 build.gradle 文件:

dependencies {
  compile fileTree(dir: 'libs', include: ['*.jar'])
  testCompile 'junit:junit:4.12'
  compile 'com.parse:parse-android:1.13.1'
  compile 'com.parse:parsefacebookutils-v4-android:1.10.4@aar'
  compile 'com.parse.bolts:bolts-tasks:1.4.0'
  compile 'com.parse.bolts:bolts-applinks:1.4.0'
  compile 'com.jeremyfeinstein.slidingmenu:library:1.3@aar'
  compile 'com.soundcloud.android:android-crop:1.0.0@aar'
  compile 'com.facebook.android:facebook-android-sdk:4.+'
  compile files('libs/universal-image-loader-1.9.3.jar')

}

这是我使用 Facebook SDK 的唯一代码点:

ParseFacebookUtils.logInWithReadPermissionsInBackground(Login.this, permissions, new LogInCallback() {
                @Override
                public void done(final ParseUser user, ParseException err) {

                    fbdialog = new ProgressDialog(Login.this);
                    fbdialog.setTitle("Contacting Facebook");
                    fbdialog.setMessage("Please wait a moment. We are contacting Facebook to perform the registration");
                    fbdialog.show();

                    if (user == null) {
                        Log.d("MyApp", "Uh oh. The user cancelled the Facebook login.");
                        fbdialog.cancel();

                    } else if (user.isNew() || !user.isNew()) {
                        Log.d("MyApp", "User signed up and logged in through Facebook!" + AccessToken.getCurrentAccessToken());

                        GraphRequest request = GraphRequest.newMeRequest(
                                AccessToken.getCurrentAccessToken(),
                                new GraphRequest.GraphJSONObjectCallback() {
                                    @Override
                                    public void onCompleted(
                                            JSONObject object,
                                            GraphResponse response) {

                                        if(response!=null) {

                                            try {
                                                String nome = object.getString("name");
                                                String email = object.getString("email");
                                                String gender = object.getString("gender");

                                                final String facebookid = object.getString("id");

                                                ParseUser utente = ParseUser.getCurrentUser();

                                                utente.put("namelastname", nome);
                                                utente.put("email", email);
                                                utente.put("gender", gender);

                                                utente.saveInBackground(new SaveCallback() {
                                                    @Override
                                                    public void done(ParseException e) {

                                                        if (e == null) {
                                                            ParseInstallation installation = ParseInstallation.getCurrentInstallation();
                                                            installation.put("idutente", user);
                                                            installation.saveInBackground();

                                                            //downloading the user profile image from facebook
                                                            AsyncTaskLoad as = new AsyncTaskLoad();
                                                            as.execute("https://graph.facebook.com/" + facebookid + "/picture?type=large");

                                                            fbdialog.cancel();

                                                        } else {

                                                            fbdialog.cancel();

                                                            e.printStackTrace();


                                                        }
                                                    }
                                                });


                                            } catch (JSONException e) {
                                                e.printStackTrace();
                                            }
                                        }
                                    }
                                });

                        Bundle parameters = new Bundle();
                        parameters.putString("fields", "id,name,link,email,age_range,gender,birthday");
                        request.setParameters(parameters);
                        request.executeAsync();


                    } else {

                        Log.d("MyApp", "User logged in through Facebook!");

                        ParseInstallation installation = ParseInstallation.getCurrentInstallation();
                        installation.put("idutente", user);
                        installation.saveInBackground();

                        fbdialog.cancel();

                        //here I start a new activity

                    }
                }
            });

        }

    });    

这是用于下载 Facebook 个人资料图片的 AsyncTask:

private class AsyncTaskLoad extends AsyncTask<String, Void, Void> {
    @Override
    protected void onPreExecute() {

        pd = new ProgressDialog(Login.this);
        pd.setTitle("Logging");
        pd.show();
    }

    @Override
    protected Void doInBackground(String... strings) {

        try {
            URL image_value = new URL(strings[0]);
            SynchroHelper sync = new SynchroHelper(Login.this);
            //simple http method to download an image and save it into a file in the external storage dir
            sync.downloadImage(image_value.toString(), "myprof.jpg", Environment.getExternalStorageDirectory());

        } catch (MalformedURLException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
        return null;

    }

    @Override
    protected void onPostExecute(Void params) {

        //starting a new activity...
        pd.dismiss();

    }

}

如何升级到 Graph API v2.0?我应该等待 Parse-SDK 的更新吗?

4

2 回答 2

2

来自fb 文档。我在您的代码中没有看到您指定了 Graph 版本,因此:

未版本化的调用将默认为 API 的最旧可用版本。未版本化的调用将始终指向图表顶部仍然可用的最旧版本。目前是 v2.0,但两年后将是 v2.1,然后是 v2.2,等等。

在这里你有更多关于图形版本的信息

于 2016-06-22T10:30:16.310 回答
2

这似乎是一个错误。已填写错误报告,目前正在调查中。

于 2016-06-22T15:38:27.437 回答