进口倾斜请求,会话和响应的Facebook SDK 4.0。 [异乎文档] [英] Cant import Request, Session and response Facebook SDK 4.0. [Egregious Documentation]

本文介绍了进口倾斜请求,会话和响应的Facebook SDK 4.0。 [异乎文档]的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用Facebook SDK 4.0,我想张贴在使用OpenGraph API用户墙。

I am using the Facebook SDK 4.0 and I want to post on users wall using the OpenGraph API.

我所定义的动作为:


  • 庆祝


  • 里程碑

现在,当Facebook的开发控制台我点击得到code和切换到Android,我得到了下面的代码片段:

Now when in the Facebook Dev console I click on get code and switch to Android I get the following snippet:

Request request = new Request(
    Session.getActiveSession(),
    "me/objects/friendsampleapp:milestone",
    params,
    HttpMethod.POST
);

Response response = request.executeAndWait();

在这里,我不能得到选项导入响应,请求和会话。

Here I cant get options to import Response, Request and Session.

我得到一个选项导入 com.facebook.login.LoginClient.Request; ,但有一个红色的波浪线,悬停时说:的类型com.facebook.login.LoginClient是不可见

I get an option to import com.facebook.login.LoginClient.Request; but with a red squiggly line which on hover says: The type com.facebook.login.LoginClient is not visible.

值得这里要注意的一点是,在同一个活动,我的登录工作正常,所以这是不是与进口Facebook的库的问题。

The point worth to note here is that in the same activity, my login is working fine so this is not an issue with importing the Facebook Library.

更新日志 Facebook上提到:

In the Changelog Facebook mentions:

会话中删除 - 的accessToken,LoginManager和CallbackManager
  班凌驾在会话级替换功能。

Session Removed - AccessToken, LoginManager and CallbackManager classes supercede and replace functionality in the Session class.

我不知道如果Facebook希望我的梦想如何连接他们的API与我的code时,其各个击破,释放SDK的这个速度,是没有帮助的人。

I wonder if Facebook expects me to dream of how to interface their API with my code when its all broken, releasing SDK's at this rate, is not helping anyone.

我也尝试登录与Facebook的错误报告,但似乎却为Facebook,就是太破!

I also tried to log a bug report with Facebook but however seems for facebook, that is broken too!

更深的挖掘,我已经改变上述code为:

Digging deeper I have changed the above code to:

Bundle params = new Bundle();
                GraphRequest request = new GraphRequest(AccessToken.getCurrentAccessToken(),"me/objects/friendsampleapp:milestone",params, HttpMethod.POST);
                GraphResponse response = request.executeAndWait();


                Bundle params1 = new Bundle();
                params1.putString("milestone", "http://samples.ogp.me/812890225461181");

                GraphRequest request1 = new GraphRequest(
                        AccessToken.getCurrentAccessToken(),"me/friendsampleapp:celebrating",params,HttpMethod.POST);
                GraphResponse response1 = request.executeAndWait();

但是,无论我很困惑,何去何从?

But however I am confused, what next?

推荐答案

下面是最后的事情,我想出了,显然,它的工作:

Here is the final thing I have come up with and apparently, it does work:

ShareOpenGraphObject object = new ShareOpenGraphObject.Builder()
                        .putString("og:type", "friendsampleapp:milestone")
                        .putString("og:title", "A Game of Thrones")
                        .putString("og:description", "In the frozen wastes to the north of Winterfell, sinister and supernatural forces are mustering.")

                        .build();


                // Create an action
                ShareOpenGraphAction action = new ShareOpenGraphAction.Builder()
                        .setActionType("friendsampleapp:celebrating")
                        .putObject("milestone", object)
                        .build();


                // Create the content
                ShareOpenGraphContent content = new ShareOpenGraphContent.Builder()
                        .setPreviewPropertyName("milestone")
                        .setAction(action)
                        .build();




                ShareDialog.show(getActivity(), content); 

这篇关于进口倾斜请求,会话和响应的Facebook SDK 4.0。 [异乎文档]的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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