在 Facebook Graph API 中获取没有用户登录的访问令牌? [英] Getting an Access Token Without User Login in Facebook Graph API?

查看:33
本文介绍了在 Facebook Graph API 中获取没有用户登录的访问令牌?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 facebook graph api rsvp_event.我正在使用 JavaScript SDK.用户登录时一切正常.但是当用户未登录时,它会给出错误.

I am working with facebook graph api rsvp_event. I am using javascript SDK. Everything works great when the user is logged in. But when the user is not logged in, it gives an error.

我需要有关谁参加公共活动的信息.我现在明白我需要一个访问令牌来检索此信息.所以,我的问题是如果没有用户登录,我如何获得访问令牌?这是不可能的还是有解决方法?是否可以使用 app_idclient_secret 在服务器端完成?

I need information about who is attending a public event. I now understand that I would need an access token to retrieve this information. So, my question is how do I get the access token if no user is logged in? Is it impossible or is there a workaround? Could it be done server side using app_id and client_secret?

我正在开发一个 ColdFusion 页面,但如果需要,我可以使用 PHP.我都支持.

I am developing a ColdFusion page, but I can use PHP if needed. I have support for both.

我听说过 *offline_access_permission* 这个词.他们已删除此功能.有空的时候可以做吗?

I have heard the term *offline_access_permission*. They have removed this feature. Could it be done when it was still available?

这可以通过 test user 来实现吗?比如说,在服务器端我通过测试用户登录,获取事件信息(只是一个获取"请求来读取谁正在参加一个事件)然后注销.在客户端,我做剩下的事情(用户登录,回复事件).

Could this be achieved by test user? Say, on server side I login via test user, get the event information (Just a "get" request to read who is attending an event) and then log off. On the client side I do the rest ( user login, rsvp to an event).

我不太了解测试用户"或其用途.谁能确认这是否可以实现?

I don't know much about "test user" or its purpose. Can anyone confirm whether this can be achieved or not?

提前致谢.

推荐答案

你确定你真的需要用户的访问令牌吗?根据这里文档,您可能需要:

Are you sure you actually need the user's access token? According to documentation here you may need:

- a generic access_token for public events (those whose privacy is set to OPEN)
- a user access_token for a user who can see the event for non-public events
- an app access_token (for non-public events, must be the app that created the event)
- a page access_token (for non-public events, must be the page that created the event)

您可以在此处获取有关如何获取这些令牌的信息 https://developers.facebook.com/docs/concepts/login/access-tokens-and-types/

You can get info on how to get those tokens here https://developers.facebook.com/docs/concepts/login/access-tokens-and-types/

当您有权访问活动时(当某个用户登录时)存储参加用户(在数据库中)是一个好主意.

A good idea could be to store the attending users (in the DB) when you have access to the event - when some user is logged in.

从 FileContent 获取数据的更新.

UPDATE for getting the data from FileContent.

我不知道您到底指的是什么 API 响应,但根据我的经验,他们正在返回数据:- 使用 JSON 序列化 - 你需要使用 DeserializeJSON(),例如这样:

I don't know what API response exactly you are referring to, but from my experience they are returning data: - serialized using JSON - you need to use DeserializeJSON(), for example like this:

local.returnStruct = DeserializeJSON( local.requestResult.FileContent );

local.returnStruct = DeserializeJSON( local.requestResult.FileContent.toString() );

  • 以类似于 URI 的形式发送.我正在使用一个函数来获取该数据:

    • send as something similar to URI. I'm using a function to get that data:

      function getStructFromQueryString( queryString ) {
          var ret = StructNew();
          var i = 0;
          var key = '';
      
          for(i=1; i LTE ListLen(arguments.queryString,'&'); i++) {
              key = ListGetAt(arguments.queryString, i, '&');
              ret[ListFirst(key,'=')] = URLDecode(ListLast(key,"="));
          }
      
          return ret;
      }
      

    • 这篇关于在 Facebook Graph API 中获取没有用户登录的访问令牌?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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