Actionscript 3 Facebook API 限制

发布于 2024-09-07 11:34:05 字数 768 浏览 3 评论 0原文

我正在使用 Actionscript 3 API 创建一个基于 Flash (AS3) 的 Facebook Connect 网站,尽管我已经具备了允许用户正确登录的基本 FB Connect 功能,但在尝试询问时却遇到了困难对于某些扩展权限。我并不肯定,但 AS3 API 似乎有两个相当重要的限制:

  1. 您必须与初始登录调用分开提示扩展权限。换句话说,需要两个模式对话框,而不是一个。这似乎是因为连接是通过 FacebookSessionUtil 的实例处理的,而扩展权限请求是通过 FacebookSessionUtil.Facebook 的实例处理的。

  2. 似乎没有办法提示用户允许他们的电子邮件地址与您的应用程序共享。虽然我仔细阅读了 http://facebook-actionscript -api.googlecode.com/svn/release/current/docs/index.html 相当彻底,看起来“EMAIL”权限仅提示用户允许您的应用通过 facebook 向他们发送电子邮件,而不是直接共享他们的电子邮件地址。

我的假设在这里是错误的吗?我使用 JS 和ExternalInterface 来完成此类工作会更好吗?我宁愿不重建现有的东西,但如果这些限制是真实的,那么我似乎别无选择。

任何反馈或帮助将不胜感激。谢谢!

I'm creating a Flash-based (AS3) Facebook Connect site using the Actionscript 3 API and though I've got basic FB Connect functionality in place in terms of allowing users to login correctly, I'm running into walls when trying to ask for certain extended permissions. I'm not positive, but it appears as though there are two fairly significant limitations to the AS3 API:

  1. You must prompt for extended permissions separately from the initial login call. In other words, two modal dialogs, not one, are required. This seems to be because connecting is handled with instances of FacebookSessionUtil, while extended permissions requests are handled by instances of FacebookSessionUtil.Facebook.

  2. It doesn't seem that there's a way to prompt users to allow their email address to be shared with your application. Though I've perused http://facebook-actionscript-api.googlecode.com/svn/release/current/docs/index.html quite thoroughly, it looks like the "EMAIL" permission there only prompts users to allow your app to send them email via facebook, not to share their email address directly.

Are my assumptions wrong here? Would I be better off using JS and ExternalInterface for this sort of work? I'd rather not rebuild what's in place but if these limitations are real, it appears I'll have no other choice.

Any feedback or assistance would be greatly appreciated. Thanks!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

木落 2024-09-14 11:34:05

1)您必须重写DesktopSession类中的onLogin函数并添加扩展权限参数。

2)它应该可以工作,除非权限模型的更改仅允许代理电子邮件。尝试从 Facebook 用户实例查询它,看看会得到什么。

开发者控制台中使用控制台块中的以下 api 调用进行测试

<button id="fb-login">Login & Permissions</button>

<script>
document.getElementById('fb-login').onclick = function() {
  var cb = function(response) {
    Log.info('FB.login callback', response);
    if (response.session) {
      Log.info('User logged in');
      if (response.perms) {
        Log.info('User granted permissions');
      }
    } else {
      Log.info('User is logged out');
    }
  };
  FB.login(cb, { perms: 'email' });
};
</script>

1)You will have to override the onLogin function in the DesktopSession Class and add in your extended permission parameters.

2)It should work unless the change in the permissions model only allowed for proxied emails. Try querying it from the facebook user instance and see what you get.

Test it in the Developer console with the following api call in the console block

<button id="fb-login">Login & Permissions</button>

<script>
document.getElementById('fb-login').onclick = function() {
  var cb = function(response) {
    Log.info('FB.login callback', response);
    if (response.session) {
      Log.info('User logged in');
      if (response.perms) {
        Log.info('User granted permissions');
      }
    } else {
      Log.info('User is logged out');
    }
  };
  FB.login(cb, { perms: 'email' });
};
</script>
梦里梦着梦中梦 2024-09-14 11:34:05

这是另一种方法,您可以直接在 AS3 中完成所有操作(非常方便),

这是我在 facebook 上构建的游戏的代码片段,需要在游戏中的某个点获得权限..它运行良好。 (请注意,您现在必须在 init 调用中指定 channel.html 和 oauth: true)

首先确保您拥有最新版本的 API(现在为 1.7)(http://code.google.com/p/ facebook-actionscript-api)

private function facebookInit():void     // START THE SESSION…
{
    Facebook.init(APP_ID, facebookInitHandler,{
        appId: APP_ID,
        status: true,
        cookie: true,
        xfmbl: true,
        channelUrl: ‘http://yoursiteurl/channel.html',
        oauth: true,
        perms: “publish_stream,email”
    });
}

private function facebookInitHandler(response:Object, fail:Object):void
{
    if (response.accessToken)
    {
        userAccessToken = JSON.encode(response.accessToken);
        facebookLoggedInWithToken = true;
        loadProfileData();
    } else {
        facebookLoggedInWithToken = false;
    }
}

private function loadProfileData():void
{
    var request:String = ‘/me’;
    var requestType:String = ‘GET’;
    var params:Object = null;
    Facebook.api(request, loadProfileDataHandler, params, requestType);
}

private function loadProfileDataHandler(response:Object, fail:Object):void
{
    if (response) {
        userID = response.id;
        fullName = response.name;
        firstName = response.first_name;
        lastName = response.last_name;
        userEmail = response.email;
        userPicURL = ‘http://graph.facebook.com/‘ + userID + ‘/picture’;
    }
}

享受吧!

here's another way you can do it all directly in your AS3 (very handy)

this is a code snippet from a game i’m building on facebook that requires permissions at a certain point in the game.. it works well. (note you now have to specify a channel.html and oauth: true in your init call)

first make sure you have the most current version of the API (now at 1.7) (http://code.google.com/p/facebook-actionscript-api)

private function facebookInit():void     // START THE SESSION…
{
    Facebook.init(APP_ID, facebookInitHandler,{
        appId: APP_ID,
        status: true,
        cookie: true,
        xfmbl: true,
        channelUrl: ‘http://yoursiteurl/channel.html',
        oauth: true,
        perms: “publish_stream,email”
    });
}

private function facebookInitHandler(response:Object, fail:Object):void
{
    if (response.accessToken)
    {
        userAccessToken = JSON.encode(response.accessToken);
        facebookLoggedInWithToken = true;
        loadProfileData();
    } else {
        facebookLoggedInWithToken = false;
    }
}

private function loadProfileData():void
{
    var request:String = ‘/me’;
    var requestType:String = ‘GET’;
    var params:Object = null;
    Facebook.api(request, loadProfileDataHandler, params, requestType);
}

private function loadProfileDataHandler(response:Object, fail:Object):void
{
    if (response) {
        userID = response.id;
        fullName = response.name;
        firstName = response.first_name;
        lastName = response.last_name;
        userEmail = response.email;
        userPicURL = ‘http://graph.facebook.com/‘ + userID + ‘/picture’;
    }
}

enjoy!

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文