2015-07-20 32 views
-2

我是android開發新手。我正在嘗試將照片從Android應用發佈到用戶的臉書相冊。我添加下面的代碼我在用戶登錄的權限「user_friends」如何使用以下圖形API從Android應用程序上傳照片到Facebook相冊?

new GraphRequest(
    MainFragment.mAccessToken.getCurrentAccessToken(), 
    "/me/photos", 
    params, 
    HttpMethod.POST, 
    new GraphRequest.Callback() { 
     public void onCompleted(GraphResponse response) { 
      /* handle the result */ 
     } 
    } 

    // This is my code for user login at app start 

    post = (Button)view.findViewById(R.id.button1); 
    mLoginManager = LoginManager.getInstance(); 
    mLoginManager.registerCallback(mCallbackManager, mCallback); 
    mLoginManager.logInWithReadPermissions(this, Arrays.asList("user_friends")); //user_friends // publish_actions 

後請指引我

+0

爲什麼user_friends?做什麼的?你只需要publish_actions。 – luschn

+0

也,你忘了提及最重要的信息:究竟是什麼問題? – luschn

+0

對不起。我錯過了很多信息。但是,我能夠找到問題並編寫工作代碼。我忘了executeAsync() –

回答

0

我做了一個錯誤..首先,我的問題是不完整的。我已經找到了問題..以下似乎工作。

 MainFragment.mLoginManager.logInWithPublishPermissions(this, Arrays.asList("publish_actions")); 
     Bundle params = new Bundle(); 

     params.putString("url", "http://www.keenthemes.com/preview/metronic/theme/assets/global/plugins/jcrop/demos/demo_files/image1.jpg"); 

/*使API調用/ 新GraphRequest( MainFragment.mAccessToken.getCurrentAccessToken(), 「/我/照片」, 參數,可以 HttpMethod.POST, 新GraphRequest.Callback( ){ 公共無效onCompleted(GraphResponse響應){ /處理結果*/ Log.d( 「MainFragment:」, 「onCompleted mAccessToken =」 + MainFragment.mAccessToken.getCurrentAccessToken());} } ).executeAsync();

相關問題