Facebook 点赞通知?

发布于 2024-10-31 06:15:32 字数 188 浏览 1 评论 0原文

我今天看到一个网站,上面写着:“分享/喜欢这个网站并获得 10% 的折扣”。我想知道:有什么方法可以跟踪有人分享/喜欢我的网站吗?我可以在我的应用程序中存储该用户的一些数据吗?

我知道这些事件有一些回调,也许我可以触发一些 jQuery 魔法,当用户单击按钮时通过 ajax 发送一些数据。

有什么想法吗?

谢谢!

I saw a website today that stated: "Share/Like this site and get 10% discount". I was wondering: is there any way to track when someone shares/likes my site? Can I store some data of that user in my app?

I know those events have some callbacks, and maybe I can trigger some jQuery magic to send some data vía ajax when the user clicks on the button.

Any ideas?

Thanks!

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

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

发布评论

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

评论(3

忆梦 2024-11-07 06:15:32

讨论了类似的问题

FB.Event.subscribe('edge.create', function(href) 
    {

    });

此处 上面的代码您只能获取 href 而不能获取任何用户详细信息。所以我厌倦了下面的代码

FB.Event.subscribe('edge.create', function (href) {             
            FB.login(function (response) {
              if (response.session) {
                //session object has uid & access token.
              }
            });

          });

上面代码中您将遇到的问题是: 由于 FB.login 会打开一个弹出窗口进行登录,因此某些浏览器会阻止弹出窗口或警告用户。
我尝试了上面的代码。 LIKE 功能可以工作并发布到用户的墙上,但关于获取用户信息:
Firefox (4.0) - 没有警告但要求用户授权APP并访问基本信息。 IE 9 - 给出了有关 POP UP 的警告消息。 Google Chrome:阻止登录弹出窗口。
似乎实现这一目标的唯一方法是让用户首先使用 Facebook Connect 登录网站,然后使用

 FB.Event.subscribe('edge.create', function (href) {
            // href is the URL of the object that got liked
            var x;
            FB.getLoginStatus(function (response) {
              alert(response);
              if (response.session) {

              }
            });

Similar question was discussed here

FB.Event.subscribe('edge.create', function(href) 
    {

    });

From the above code you can get only href not any User details. So I tired the following code

FB.Event.subscribe('edge.create', function (href) {             
            FB.login(function (response) {
              if (response.session) {
                //session object has uid & access token.
              }
            });

          });

The Problem you will have from above code is: Since FB.login will open a pop up window for log in, some browsers will block the pop up or warns the user.
I tried the above code. LIKE functionality works and is posted to user's wall, but regarding getting user info:
Firefox (4.0) - did not warn but it asked the user to authorize APP and access basic information. IE 9 - Gave a warning message about POP UP. Google Chrome : Blocked the log in pop up.
It seems the only way to achieve this is let the user login to website using Facebook Connect first and then get user info using

 FB.Event.subscribe('edge.create', function (href) {
            // href is the URL of the object that got liked
            var x;
            FB.getLoginStatus(function (response) {
              alert(response);
              if (response.session) {

              }
            });
聊慰 2024-11-07 06:15:32

Check out the Facebook developers site. It contains heaps of information.

http://developers.facebook.com/search?q=Events.create

and

http://developers.facebook.com/blog/post/149/

久伴你 2024-11-07 06:15:32

像这样的事情应该可以满足您的需要:

<fb:like href="http://www.google.com"></fb:like>
<!-- Like button to whatever object you want^^ -->

<div id="fb-root"></div>
<script src="http://connect.facebook.net/en_US/all.js" 
    type="text/javascript" charset="utf-8"></script>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.5.1/jquery.min.js" 
    type="text/javascript" charset="utf-8"></script>
<script type="text/javascript" charset="utf-8">
    FB.init({
        appId: 'APP_ID', 
        status: true, 
        cookie: true,
        xfbml: true
    });

    FB.Event.subscribe('edge.create', function(href) 
    {
        // href is the URL of the object that got liked

        // do whatever magic ajax you want
    });
</script>

Something like this should do what you need:

<fb:like href="http://www.google.com"></fb:like>
<!-- Like button to whatever object you want^^ -->

<div id="fb-root"></div>
<script src="http://connect.facebook.net/en_US/all.js" 
    type="text/javascript" charset="utf-8"></script>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.5.1/jquery.min.js" 
    type="text/javascript" charset="utf-8"></script>
<script type="text/javascript" charset="utf-8">
    FB.init({
        appId: 'APP_ID', 
        status: true, 
        cookie: true,
        xfbml: true
    });

    FB.Event.subscribe('edge.create', function(href) 
    {
        // href is the URL of the object that got liked

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