12

Używam pakietu SDK Parse w mojej aplikacji (https://github.com/ParsePlatform/Parse-SDK-Android).Analiza SDK Android - Facebook Graph API v2.0

Moja aplikacja używa również Facebook Utils w celu zapewnienia doświadczenie Login with Facebook (https://github.com/ParsePlatform/ParseFacebookUtils-Android)

Niedawno otrzymaliśmy następującą wiadomość od Facebooka deweloperów odnośnie do jednego z mojej aplikacji: „xxx poczyniła ostatnia Wywołania API do Graph API v2.0, które osiągną koniec 2-letniego okna wycofania w poniedziałek, 8 sierpnia 2016 r. Należy migrować wszystkie wywołania do wersji 2.1 lub nowszej, aby uniknąć potencjalnych problemów. "

Jak mogę rozwiązać ten problem?

To jest mój plik build.gradle w sekcji dependecies:

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:[email protected]' 
    compile 'com.parse.bolts:bolts-tasks:1.4.0' 
    compile 'com.parse.bolts:bolts-applinks:1.4.0' 
    compile 'com.jeremyfeinstein.slidingmenu:library:[email protected]' 
    compile 'com.soundcloud.android:android-crop:[email protected]' 
    compile 'com.facebook.android:facebook-android-sdk:4.+' 
    compile files('libs/universal-image-loader-1.9.3.jar') 

} 

i jest to jedyny punkt w kodzie gdzie używam 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 

        } 
       } 
      }); 

     } 

    });  

to AsyncTask używany aby pobrać obraz profilu Facebook:

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(); 

    } 

} 

Jak mogę uaktualnić do Graph API v2.0? Czy powinienem czekać na aktualizację z pakietu Parse-SDK?

+0

Mam również ten e-mail, nie mam pojęcia, jak to naprawić. – Josh

Odpowiedz

2

Wydaje się, że to błąd. Plik bug report został wypełniony i jest obecnie badany.

2

Od fb docs. Nie widzę w twoim kodzie, że określasz wersję Graph tak, aby:

Niewersjonowane połączenie będzie domyślnie najstarszą dostępną wersją interfejsu API. Niewersjonowane wywołanie zawsze wskazuje najstarszą wersję nadal dostępną u góry wykresu. Jest to obecnie v2.0, ale po dwóch latach będzie to v2.1, v2.2 następnie itp

Tutaj masz więcej inforamtion o graph version