简体   繁体   English

Facebook Graph API“/ userid / feed”返回Blank

[英]Facebook Graph API “/userid/feed” returning Blank

I'm using Facebook C# SDK and I can't seem to get feed data back using Graph API. 我正在使用Facebook C#SDK,我似乎无法使用Graph API获取Feed数据。

I've obtained the following extended permissions from the user: 我从用户那里获得了以下扩展权限:

scope=offline_access,publish_stream,publish_checkins,create_event,read_stream,user_about_me,user_events,user_hometown,user_location,user_photos,read_friendlists,read_requests,user_checkins,user_relationships,user_online_presence,user_notes,user_likes,user_work_history 范围= offline_access,publish_stream,publish_checkins,create_event,read_stream,user_about_me,user_events,user_hometown,USER_LOCATION,user_photos,read_friendlists,read_requests,user_checkins,user_relationships,user_online_presence,user_notes,user_likes,user_work_history

I have an access token for offline access. 我有一个用于离线访问的访问令牌。

I'm able to retrieve userid/friends information without a hitch, but can't seem to get feed data. 我能够毫不费力地检索用户ID /朋友信息,但似乎无法获取Feed数据。

I get the following returned: 我得到以下返回:

{
   "data": [

   ]
}

I obtained the token with type="client_cred" if that makes a difference. 我获得了type =“client_cred”的令牌,如果这有所不同的话。 The process runs with user offline, so I'm not using the "me" alias. 该进程在用户离线时运行,因此我不使用“me”别名。

Can someone give some direction on what I'm doing wrong? 有人能指出我做错了吗?

A token obtained with type=client_cred means "the application on behalf of itself", rather than "the application on behalf of a specific user". 使用type = client_cred获得的令牌表示“代表自身的应用程序”,而不是“代表特定用户的应用程序”。 This means that it can only see stuff that's visible to all users. 这意味着它只能看到所有用户都可以看到的内容。 If you want to grab information on behalf of a particular user, you need to use that user's access token that you acquired. 如果您想代表特定用户获取信息,则需要使用您获取的该用户的访问令牌。 Since you asked for offline_access, when you acquire an access token for a user, that token won't expire quickly, and you can keep it around in a database. 由于您要求offline_access,当您为用户获取访问令牌时,该令牌不会很快过期,您可以将其保留在数据库中。

FB.init({ appId : 'YOUR APP ID', status : true, // check login status cookie : true, // enable cookies to allow the server to access the session xfbml : true // parse XFBML }); FB.init({appId:'你的APP ID',状态:true,//检查登录状态cookie:true,//启用cookie以允许服务器访问会话xfbml:true //解析XFBML});

Once you add this code. 添加此代码后。 Facebook sets a cookie on you domain. Facebook在您的域名上设置了一个cookie。 The name of the cookie would be fbs_ YourAppId . cookie的名称是fbs_ YourAppId

You can read the cookie and get the access_token. 您可以阅读cookie并获取access_token。

Alternately you can use a method provided by the Facebook Api Connect.js file to get the feed if the user is logged in. 或者,如果用户已登录,您可以使用Facebook Api Connect.js文件提供的方法来获取Feed。

FB.Api(). FB.Api()。 Please refer to http://developers.facebook.com/docs/reference/javascript/fb.api/ to know more about the method. 请参阅http://developers.facebook.com/docs/reference/javascript/fb.api/以了解有关该方法的更多信息。

Happy coding :) 快乐编码:)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM