2013-12-20 14 views
0

我已經實現了一個應用程序,我的用戶可以發佈在他們的Facebook帳戶。 但是當我登錄爲開發者帳戶,然後它的工作,但是當我使用不同的用戶ID,然後在它顯示一個消息「與Facebook驗證失敗!」不能登錄我的Facebook與Android應用程序集成使用不同的用戶ID

btnPostStatus = (Button) findViewById(R.id.postStatus); 
     edtPost = (EditText)findViewById(R.id.post_text); 

     btnPostStatus.setOnClickListener(new OnClickListener() { 

      public void onClick(View view) { 

       facebook = new Facebook(APP_ID); 
       restoreCredentials(facebook); 
       messagePost = edtPost.getText().toString(); 
       if (!facebook.isSessionValid()) { 
        loginAndPostToWall(); 
       } else { 
        postToWall(messagePost); 
       } 
      } 
     }); 

public void loginAndPostToWall() { 
     facebook.authorize(this, PERMISSIONS, Facebook.FORCE_DIALOG_AUTH, 
       new LoginDialogListener()); 
    } 

    public void postToWall(String message) { 
     Bundle parameters = new Bundle(); 
     parameters.putString("message", message); 
     parameters.putString("description", "topic share"); 
     try { 
      facebook.request("me"); 
      String response = facebook.request("me/feed", parameters, "POST"); 
      Log.d("Tests", "got response: " + response); 
      if (response == null || response.equals("") 
        || response.equals("false")) { 
       showToast("Blank response."); 
      } else { 
       showToast("Message posted to your facebook wall!"); 
      } 
     } catch (Exception e) { 
      showToast("Failed to post to wall!"); 
      e.printStackTrace(); 
     } 
    } 

回答

3

在Facebook中:轉到Mannage應用程序 - >選擇您的應用程序 - >設置 - 將沙箱模式更改爲關閉。 它的工作原理。

+0

Thnx很多,現在工作。 – Kunu

0

你加入這一行您的清單

<meta-data android:name="com.facebook.sdk.ApplicationId" android:value="@string/app_id"/> 

,並添加APP_ID到您的strings.xml文件

+0

不,不需要,他需要關閉沙箱模式 – NightSkyCode

+0

@NightSky我可以在哪裏關閉沙箱模式? – Kunu

相關問題