验证在我的网站上显示我的墙 [英] Authentication to display my Wall on my website

查看:122
本文介绍了验证在我的网站上显示我的墙的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我正在尝试让我的Facebook墙上的帖子的JSON对象显示在我的网站上,但这似乎非常复杂。我需要实现服务器端重定向,然后将数据发回假装成为用户,以便我可以得到一个令牌,或者我误解了这里的一些东西?



如何请求我的Wall Stream的JSON对象,因为我有一个API密钥&秘密等?目前,我无法弄清楚如何将这些细节变成一个正确的access_token,实际上可以与 FacebookClient.Get(Me,参数)一起使用。



我已经读过某个地方可以得到一个永远不会过期但按照给出的步骤的无限会话密钥 here 只是在第二次发生错误步。



我已经阅读了大量文档,并尝试查找示例,但几乎我发现的所有内容都在身份验证后启动。



非常感谢任何帮助。

解决方案

获得访问令牌(没有得到这个)。这通过OAuth对话框进行,用户登录并提供所需的权限。您将不得不请求offline_access和read_stream权限来执行您尝试的操作。获取access_token非常简单。按照这里的说明: http://osnapz.wordpress.com/2010/04/23/using-asp-net-with-facebooks-graph-api-and-oauth-2-0-authentication/



另外,阅读Facebook的文档: http ://developers.facebook.com/docs/authentication/



您必须将您的访问令牌存储在某个地方以备以后使用(这是无限会话键)



获取访问令牌后,您可以直接调用图形API:

 https://graph.facebook.com/me/feed/?access_token=YOUR-TOKEN-HERE 

或者您可以使用Facebook C#SDK(推荐)



FYI,您发布的链接已经过期,Facebook不会很快支持该方法。



更新 - 手动访问方式TOKEN:



由于您只对您的数据感兴趣,所以您只需要获取访问令牌。当然,如果您更改密码,您将不得不再次执行此操作。



我将详细说明获取令牌的手动方式。


  1. 确保您使用的是Firefox。它实际上显示JSON字符串。

  2. 导航到此URL。添加您的应用程序ID,回调URL(这应该与您注册的域匹配)。我已经添加了很多权限。

https: facebook.com/dialog/oauth?display=popup&client_id=YOUR-APP-ID&redirect_uri=YOUR-CALLBACK-URL&scope=offline_access,read_stream,email,read_insights,user_events,user_groups,user_interests,user_likes,user_location,user_notes, user_photo_video_tags,用户_照片,user_relationships,user_religion_politics,user_status,user_videos,user_website,user_work_history,read_friendlists,read_requests,friends_likes,friends_location,friends_notes,friends_photo_video_tags,friends_photos,friends_relationships,friends_religion_politics,friends_status,friends_videos,friends_website,friends_work_history,user_checkins,friends_checkins




  1. 一旦你验证和允许,Facebook将重定向到你的回调URL是一个代码参数。记下此参数。


  2. 现在调用另一个URL,添加您的应用程序ID,api密码和代码。


https://graph.facebook.com/oauth/access_token?client_id=YOUR-APP-ID&redirect_uri=您的电话 - URL& client_secret = API-SECRET& code = CODE-YOUR-COPIED-BEFORE


  1. 调用上面的URL将在浏览器中显示访问令牌。保存此访问令牌。现在,您可以使用此令牌代替您进行API调用。


  2. 请记住,如果您更改密码,您将再次进行此过程。 p>


这是一种手动方式,只适用于您仅对您的数据感兴趣的场景。我这样做是为了测试目的。


I'm trying to get a JSON object of my Facebook wall posts to display on my website but it seems to be ridiculously complicated for such a simple task.

Do I need to implement server-side redirects and then post data back 'pretending' to be a user just so that I can get a token or am I misunderstanding something here?!

How can I request the JSON object of my Wall Stream given the fact that I have an API key & secret etc? Currently I can't work out how to turn these details into a proper access_token that can actually be used with FacebookClient.Get("Me", parameters).

I've read somewhere that I can get an infinite session key that will never expire but following the steps given here simply cause an error at the 2nd step.

I have read loads of documentation and tried to find examples but almost everything I've found starts after authentication.

Any help is much appreciated.

解决方案

First, you need to get an access token (there is no getting around this). This is done via an OAuth Dialog where the user signs-in and provides the required permission. You will have to request the "offline_access" and "read_stream" permissions to do what you are trying to. Getting the access_token is pretty simple. Follow the instruction here: http://osnapz.wordpress.com/2010/04/23/using-asp-net-with-facebooks-graph-api-and-oauth-2-0-authentication/

Also, read up Facebook's documentation: http://developers.facebook.com/docs/authentication/

You will have to store your access token somewhere for later use (this is the infinite session key)

After you get the access token, you can call the graph API directly:

https://graph.facebook.com/me/feed/?access_token=YOUR-TOKEN-HERE

OR you can use the Facebook C# SDK (recommended).

FYI, the link you posted is out-dated and Facebook will not support that method soon.

UPDATE - MANUAL WAY OF GETTING AN ACCESS TOKEN:

Since you are only interested in your data, so you will only have to get the access token ONCE. Of course, you will have to do this again if you change your password.

I will detail a manual way of getting your token.

  1. Make sure you are using Firefox. It actually displays JSON strings.
  2. Navigate to this URL. Add your App ID, callback-url (this should match the domain you in your registration). I have added a lot of permissions.

https://www.facebook.com/dialog/oauth?display=popup&client_id=YOUR-APP-ID&redirect_uri=YOUR-CALLBACK-URL&scope=offline_access,read_stream,email,read_insights,user_events,user_groups,user_interests,user_likes,user_location,user_notes,user_photo_video_tags,user_photos,user_relationships,user_religion_politics,user_status,user_videos,user_website,user_work_history,read_friendlists,read_requests,friends_likes,friends_location,friends_notes,friends_photo_video_tags,friends_photos,friends_relationships,friends_religion_politics,friends_status,friends_videos,friends_website,friends_work_history,user_checkins,friends_checkins

  1. Once you authenticate and "Allow", Facebook will redirect to your callback URL is a "code" parameter. Make a note of this parameter.

  2. Now call another URL, add your app id, api secret, and the code.

https://graph.facebook.com/oauth/access_token?client_id=YOUR-APP-ID&redirect_uri=YOUR-CALLBACK-URL&client_secret=API-SECRET&code=CODE-YOUR-COPIED-BEFORE

  1. Calling the URL above will display the access token in the browser. Save this access token. Now you can use this token to make API calls on your behalf.

  2. Remember, you will have go through this process again if you change your password.

This is a manual way and only intended in your scenario where you are only interested in your data. I do this for testing purposes.

这篇关于验证在我的网站上显示我的墙的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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