0

我正在使用 android 开发 facebook sdk 3.0,需要向朋友发送请求,我的代码是:-

私人无效发送请求对话(){

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

当我单击“发送”按钮时,Toast 即将发送请求,但请求没有发送给朋友,也没有通知该朋友,但我需要这个,我不知道有什么问题,请帮助我;)

4

3 回答 3

1

那是因为您的应用程序处于沙盒模式。禁用沙盒模式。它可以工作

于 2013-06-18T10:09:36.063 回答
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();
}
于 2013-05-05T08:55:17.980 回答
1

您需要在 Bundle 参数中添加您朋友的 facebook id。

params.putString("to", uid);

于 2013-05-05T04:28:59.183 回答