创建了Facebook SDK 4请求(Android版) [英] Create a Request in Facebook SDK 4 (Android)

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

问题描述

据我了解,Facebook的SDK V4不使用会话了,但我自己的图形API文档阅读,会话仍用于创建请求

As I understand, Facebook SDK v4 doesn't use the Session anymore, but I read in their Graph API document, the session is still used to create the Request

https://developers.facebook.com/文档/图形的API /使用-图形的API / V2.3

/* make the API call */
new Request(
    session,
    "/me",
    null,
    HttpMethod.GET,
    new Request.Callback() {
        public void onCompleted(Response response) {
            /* handle the result */
        }
    }
).executeAsync();

这是困惑我,我怎么能得到会话请求?任何最新的例子,通过使用Facebook的图形API,以获取用户配置文件数据?

It's confusing me, and how can I get the session for Request? Any latest example to get the user profile data by using Facebook Graph API?

任何意见是AP preciated。

Any advice is appreciated.

推荐答案

在Facebook开发的页面发布更新日志和升级后。你的情况,这将是一个选项:

On facebook developers' page is published a changelog and upgrade post. In your case this would be an option:

GraphRequest request = GraphRequest.newMeRequest(accessToken, new GraphRequest.GraphJSONObjectCallback() {
            @Override
            public void onCompleted(JSONObject user, GraphResponse response) {
                /* handle the result */
            }
    }).executeAsync();

顺便说一句,他们指定此:

By the way, they specify this:

在默认情况下一个newMeRequest方法从用户对象获取默认字段。如果您需要任何额外的字段,或者想降低性能的原因响应的负载,你可以添加一个字段参数,并要求具体领域。

By default a newMeRequest method fetches default fields from a user object. If you need any additional fields, or want to reduce the response payload for performance reasons, you can add a fields parameter and request specific fields.

例如:

GraphRequest request = GraphRequest.newMeRequest(
    accessToken,
    new GraphRequest.GraphJSONObjectCallback() {
        @Override
        public void onCompleted(
               JSONObject object,
               GraphResponse response) {
            // Application code
        }
    });
Bundle parameters = new Bundle();
parameters.putString("fields", "id,name,link");
request.setParameters(parameters);
request.executeAsync();

我希望我的回答可以帮助你,这是我的一个计算器中的第一个答案。问候。

I hope my answer helps you, being this one my first answer in stackoverflow. Greetings.

参考: Facebook的Andr​​oid SDK中升级

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

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