如何使用 Facebook OpenGraph 实现客户个性化?

发布于 2024-12-29 07:34:04 字数 216 浏览 1 评论 0原文

我目前正在将 OpenGraph 集成到一家餐厅业务中。提供的代码/脚本在暂存环境中似乎运行良好,但我想更进一步:当一个人访问该网站并登录到 Facebook 时,我想为他们显示一条特定消息。

假设他们的名字是史蒂文史密斯,我想在网站顶部添加一个部分,其中写着“欢迎史蒂文,您想做什么?”,并提供三个选项以及相关页面的链接。

我需要为此编写脚本吗?或者是我在可用的工具中错过了一些东西?

I'm currently integrating the OpenGraph into a restaurant business. The code/scripts provided seem to work fine in a staging environment, however I want to go one step further: when a person visits the site, and they're logged in to Facebook, I would like to display a specific message for them.

Let's say their name it Steven Smith, I would like to add a section at the top of the site which says "Welcome Steven, what would you like to do?", with three options provided with links to relevant pages.

Is this something that I will need to write a script for? Or is it something that I have missed with the tools available?

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

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

发布评论

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

评论(3

趁年轻赶紧闹 2025-01-05 07:34:04

这称为“即时个性化”,仅适用于少数精选的 Facebook 合作伙伴。

This is called 'instant personalization' and is only available to a select few Facebook partners.

妖妓 2025-01-05 07:34:04

首先,您需要设置一个应用,让用户对您的应用进行身份验证,然后当用户访问该页面时,您调用 FB.getLoginStatus() 来查看他们是否已连接到您的应用程序。如果是这样,您就知道他们是谁并且可以显示他们的名字。请参阅:https://developers.facebook.com/docs/reference/javascript/

FB.getLoginStatus(function(response) {      
    if (response.status=='connected') {
        FB.api('/me',function(response){
            alert('Welcome back ' + response.name);
        });
    }
});

First, you will need to setup an app, have the user authenticate to your app, and then when the user comes to the page and you call FB.getLoginStatus() to see if they're already connected to your app. If so, you know who they are and can display their name. See: https://developers.facebook.com/docs/reference/javascript/

FB.getLoginStatus(function(response) {      
    if (response.status=='connected') {
        FB.api('/me',function(response){
            alert('Welcome back ' + response.name);
        });
    }
});
满栀 2025-01-05 07:34:04

正如您的规范所说,这正是您想要实现的目标:

https:// Developers.facebook.com/docs/reference/javascript/FB.login/

您需要fb应用程序进行身份验证,身份验证后,获得只读权限(最小的权限,不能发帖或点赞),

然后,

 FB.login(function(response) {
   if (response.authResponse) {
     DisplayFunc('Welcome!  Fetching your information.... ');
     FB.api('/me', function(response) {
       DisplayFunc('Good to see you, ' + response.name + '.');
     });
   } else {
     DisplayFunc('User cancelled login or did not fully authorize.');
   }
 });

As your spec says, this covers exactly what you want to achieve:

https://developers.facebook.com/docs/reference/javascript/FB.login/

You need fb app to auth, after auth, get the permission for reading only (minimal one which can't post or like),

then,

 FB.login(function(response) {
   if (response.authResponse) {
     DisplayFunc('Welcome!  Fetching your information.... ');
     FB.api('/me', function(response) {
       DisplayFunc('Good to see you, ' + response.name + '.');
     });
   } else {
     DisplayFunc('User cancelled login or did not fully authorize.');
   }
 });
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文