2013-05-05 50 views
0

我在Android平臺上的Facebook SDK 3.0和需要發送請求給朋友 和我的代碼是: -如何在Facebook SDK發送請求3.0的Android

私人無效sendRequestDialog(){

Bundle params = new Bundle(); 

    params.putString("message", 
      "Learn how to make your Android apps social"); 

    WebDialog requestsDialog = (new WebDialog.RequestsDialogBuilder(
      Logout.this, Session.getActiveSession(), params)) 
      .setOnCompleteListener(new OnCompleteListener() { 

       @Override 
       public void onComplete(Bundle values, 
         FacebookException error) { 
        if (error != null) { 
         if (error instanceof FacebookOperationCanceledException) { 
          Toast.makeText(
            Logout.this.getApplicationContext(), 
            "Request cancelled", Toast.LENGTH_SHORT) 
            .show(); 
         } else { 
          Toast.makeText(
            Logout.this.getApplicationContext(), 
            "Network Error", Toast.LENGTH_SHORT) 
            .show(); 
         } 
        } else { 
         final String requestId = values 
           .getString("request"); 
         if (requestId != null) { 
          Toast.makeText(
            Logout.this.getApplicationContext(), 
            "Request sent", Toast.LENGTH_SHORT) 
            .show(); 
         } else { 
          Toast.makeText(
            Logout.this.getApplicationContext(), 
            "Request cancelled", Toast.LENGTH_SHORT) 
            .show(); 
         } 
        } 
       } 
      }).build(); 
    requestsDialog.show(); 
} 

當我點擊發送按鈕吐司即將於發送請求,但請求不來朋友沒有通知來的是朋友,但我需要這個我沒有得到什麼problum請幫助我。)

+0

我有同樣的問題,我也與PARAMS uid和requst發送敬酒嘗試是有,但沒有請求進來的朋友資料..如果你找到任何解決方案,然後請告訴.. – Pranav 2014-06-18 17:59:36

回答

1

您需要在Bundle params中添加朋友的Facebook ID。

params.putString("to", uid);

+0

,但我將如何獲得所有朋友的身份證? – Arun 2013-05-05 05:19:10

+0

我沒有得到如何獲得uid? – Arun 2013-05-05 05:40:38

+0

它不工作我已經通過身份證我怎麼辦? – Arun 2013-05-05 07:21:43

1
private void sendInviteDialog(String uid,final int position) { 
    Bundle params = new Bundle(); 
    params.putString("to", uid); 
    params.putString("message", "Please try my app"); 
    WebDialog requestsDialog = (
     new WebDialog.RequestsDialogBuilder(getActivity(), 
      Session.getActiveSession(), 
      params)) 
      .setOnCompleteListener(new OnCompleteListener() { 
       @Override 
       public void onComplete(Bundle values,FacebookException error) { 
        if (error != null) { 
         if (error instanceof FacebookOperationCanceledException) { 
          MessageUtil.showMessage("Request cancelled", true); 
         } else { 
          MessageUtil.showMessage(ResourcesUtil.getString(R.string.network_unavailable), true); 
         } 
        } else { 
         final String requestId = values.getString("request"); 
         if (requestId != null) { 
          MessageUtil.showMessage(ResourcesUtil.getString(R.string.friend_request_sent), true); 
         } else { 
          MessageUtil.showMessage(ResourcesUtil.getString(R.string.request_not_successful), true); 
         } 
        } 
        mProgressDialog.dismiss(); 
       } 

      }) 
      .build(); 
    requestsDialog.show(); 
} 
+0

是任何額外的permition要求我只是在我的應用程序使用應用程序ID? – Arun 2013-05-05 11:57:26

1

那是因爲你的應用程序是在沙盒mode.Disable沙箱mode.It工作

相關問題