缺少使用Facebook的开放图谱访问令牌 [英] Missing access token using Facebook Open Graph

查看:566
本文介绍了缺少使用Facebook的开放图谱访问令牌的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用Facebook SDK在Android上发送像使用开放图形API的状态。这里描述: https://developers.facebook.com/docs/opengraph/actions /内置/喜欢/ 出租车从SDK我得到access_token使用SSO(带publish_actions许可)。我已经registred我在Facebook开发应用程序的帐户,所以我有我的APP_ID。照片下面我想使用开放图谱API发送般的地位在我的墙上。所以,我呼吁 https://graph.facebook.com/MY_USER_ID/og.likes 与access_token,APP_ID和对象头(使用调用setRequestProperty())与HttpURLConnection类和setRequestMethod开机自检。

I want to use Facebook SDK on Android to send Like statuses using Open Graph API. Described here: https://developers.facebook.com/docs/opengraph/actions/builtin/likes/
From SDK I got access_token (with publish_actions permission) using SSO. I already registred my app on Facebook Dev Account so I have my app_id.
Now I want to use Open Graph API to send Like status on my wall. So I call https://graph.facebook.com/MY_USER_ID/og.likes with access_token, app_id and object header (using setRequestProperty()) with HttpURLConnection and setRequestMethod to POST.

HttpURLConnection conn;
conn.setRequestMethod("POST");
conn.setDoOutput(true);
conn.setRequestProperty("object", "someURL");
conn.setRequestProperty("app_id", "myID");
conn.setRequestProperty("access_token", "myToken");
conn.setRequestProperty("Content-Length", "" + postMessageInBytes.length);

我总是得到响应400错误的请求

I always get response 400 Bad Request

  {"error":{"message":"An access token is required to request this resource.","type":"OAuthException","code":104}} 

在我使用的图形API浏览器(developers.facebook.com/tool​​s/explorer/)一切工作正常,并没有与访问令牌没有问题。
当我调试我的访问令牌一切正常(译自其他语言):

When I'm using Graph API Explorer (developers.facebook.com/tools/explorer/) everything works fine and there is no problem with access token.
When I debug my access token everything looks fine (translated from another language):

ID app: my app ID/name
ID user: user which I used to login
Issued: 1348929549 (yesterday)
Valid until: 1354113549 (in about 2 months)
Valid:  True
Origin: Mobile Web Faceweb
Permission: publish_actions user_status

所以,问题是,在与访问令牌问题?
感谢您的帮助!

So the question is, where is the problem with access token?
Thanks for help!

推荐答案

我不知道究竟是问题,但我开始使用AsyncFacebookRunner这是Facebook的SDK的一部分,现在一切工作正常。正如我可以从AsyncFacebookRunner一样的东西源$ C ​​$ C见完有点不同。

编辑: 简单的要求对于喜欢动作

I don't know where exactly was problem, but I started to use AsyncFacebookRunner which is part of Facebook SDK and everything now works fine. As I can see from source code of AsyncFacebookRunner same things are done little bit different.

Simple request for Like action

Bundle msgParams = new Bundle();
msgParams.putString("object", mUrl);
Request request = new Request(Session.getActiveSession(), "me/og.likes", msgParams, HttpMethod.POST,
                likeCallback);
RequestAsyncTask task = new RequestAsyncTask(request);
task.execute();

这篇关于缺少使用Facebook的开放图谱访问令牌的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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