0

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

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

有任何想法吗?

谢谢!

4

3 回答 3

1

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) {

              }
            });
于 2011-04-08T15:33:13.233 回答
0

查看 Facebook 开发者网站。它包含大量信息。

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

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

于 2011-04-08T01:51:17.873 回答
0

像这样的东西应该做你需要的:

<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>
于 2011-04-08T02:05:21.793 回答