申请Android Facebook SDK 3.0 [英] Apprequest of Android Facebook sdk 3.0

查看:103
本文介绍了申请Android Facebook SDK 3.0的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用更新的Android版Facebook SDK V3.0 final.我正在尝试将应用程序请求发送给没有该应用程序的Facebook朋友.代码是:

I am using the updated Facebook SDK V3.0 final for Android. I am trying to send app requests to facebook frineds who do not have the application. The code is:

public void fbookinvite(){

        Bundle postParams = new Bundle();
        postParams.putString("name", "X");
        postParams.putString("message", "DOWNLOAD X.");

        Session session = Session.getActiveSession();

        postParams.putString("access_token", session.getAccessToken());

        if (session==null||session.getState().isClosed()){
            System.out.println("session is null");
        }else{
            //meaning we are good to go.
            Request request = new Request(session,"/friend facebook id/apprequests", postParams, HttpMethod.POST, new Request.Callback() {

                @Override
                public void onCompleted(Response response) {

                    System.out.println("response was: "+response.toString());
                }

            });

            Request.executeBatchAsync(request);
        }       
    }

代码运行时,我从打印的响应中获得以下内容之一:

When the code runs I get one of the following from the printed response:

responseCode: 400, graphObject: null, error: {HttpStatus: 400, errorCode: 2, errorType: OAuthException, errorMessage: (#2) Failed to create any app request}, isFromCache:false

...或:

Response:  responseCode: unknown, graphObject: null, error: {HttpStatus: -1, errorCode: -1, errorType: null, errorMessage: null}, isFromCache:false}

我具有以下权限:publist_streampublish_actions.

解决问题后,我还想知道如何向应用程序请求中添加一组收件人.

After solving the problem I'd also like to know how to add a group of recipients to the app request.

我不想使用Facebook对话框.

I do not want to use the Facebook dialog.

推荐答案

尝试以下方法:

        Bundle params = new Bundle();   
        params.putString("message",
                "Learn how to make your Android apps social");
        params.putString("to", "YOUR_FRIEND_UID_HERE");
        WebDialog requestsDialog = (new WebDialog.RequestsDialogBuilder(
                this, Session.getActiveSession(), params))
                .setOnCompleteListener(new OnCompleteListener() {

                    @Override
                    public void onComplete(Bundle values,
                            FacebookException error) {
                        // your code here 
                    }

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

这是将应用请求显式发送给某人的正确方法.如果您不包括to参数,则用户可以选择要发送给谁.

This is the proper way to send an app request explicitly to someone. If you do not include the to parameter, the user can choose who they want to send to.

这篇关于申请Android Facebook SDK 3.0的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆