2014-01-26 30 views
1

我已通過我的Android應用成功上傳照片到Facebook,該應用存在於爲我的應用創建的相冊中,但照片需要由用戶手動批准,並且Facebook表示:通過Android上傳的照片未在Facebook上獲得批准

Would you like to add these photos to your album? 
The photos below were uploaded from another application, you'll need to approve them. 

它看起來像這樣在Facebook上:

enter image description here

順便說一句,我已經添加了user_photos許可。這裏是上傳代碼:

public void uploadToFB(Uri photo){ 

    Session session = Session.getActiveSession(); 
    Bundle bundle = new Bundle(); 
    bundle.putString("url", "http://6269-9001.zippykid.netdna-cdn.com/wp-content/uploads/2013/09/Cute-Dog-Wallpaper-Pictures.jpg");   

    new Request(
     session, 
     "/me/photos", 
     bundle, 
     HttpMethod.POST, 
     new Request.Callback() { 
      @Override 
      public void onCompleted(Response response) { 
       dialog.dismiss(); 

      } 
     } 
    ).executeAsync(); 

} 

在MainActivity:

@Override 
protected void onResumeFragments() { 
    super.onResumeFragments(); 
    Session session = Session.getActiveSession(); 

    if (session != null && session.isOpened()) { 
     startActivity(new Intent(this, LoggedMainActivity.class)); 
    } else { 
     showLoginFragment();    
    } 
} 

private void showLoginFragment(){ 
    LoginFragment login=new LoginFragment(); 
     getSupportFragmentManager() 
     .beginTransaction() 
     .add(android.R.id.content, login) 
     .commit(); 
} 

這是LoginFragment:

public class LoginFragment extends Fragment { 

private LoginButton authButton; 

@Override 
public View onCreateView(LayoutInflater inflater, 
     ViewGroup container, Bundle savedInstanceState) { 
    View view = inflater.inflate(R.layout.login_fragment, 
      container, false); 
    authButton=(LoginButton)view.findViewById(R.id.login_button); 
    authButton.setReadPermissions(Arrays.asList("user_photos","publish_stream","read_stream")); 
    return view; 
} 

} 
+0

請附上您用於將照片發佈到Facebook的代碼。 –

+0

@Salman Ayub,好吧,它現在被添加 –

+0

您使用Facebook登錄窗口小部件嗎?對於認證?我認爲你錯過了一些權限。 –

回答

1

你缺少publish_stream權限在您Facebook Login Widget

下面是演示如何添加權限:

/*LoginButton authButton = (LoginButton) findViewById(R.id.YOUR_ID); 
authButton.setReadPermissions(Arrays.asList("user_photos")); 
authButton.setPublishPermissions(Arrays.asList("publish_stream","read_stream"));*/ 

這些權限只需添加到您的登錄窗,一切都應該正常工作。

編輯:
Setting up Read and Publish Permissions together :
Get Read and Publish Permissions in one request

我希望這有助於。

+0

嗨,我在添加上面的權限時出錯,錯誤是:無法將發佈或管理權限(publish_stream)傳遞給讀取授權請求。任何提示:) –

+0

是的,我預計:)你有一些衝突的權限。請發佈您的Facebook登錄Widget的初始化代碼。 –

+0

非常感謝,我已經添加了。 –