Facebook:了解用户何时喜欢网址

时间:2012-11-16 13:49:17

标签: facebook facebook-graph-api facebook-like

我可以从 user_id - url 表中获得一对 url_like
如上所述,只有两列是 user_id, url

我试图通过多种方式获取“喜欢”URL的日期,通过连接多个表,但没有运气。
其中一个例子可能是

SELECT url, id, type, site FROM object_url WHERE url IN (
    SELECT url FROM url_like WHERE user_id = {$target}
) LIMIT 1000",

有什么方法可以获取用户喜欢特定网址的日期/时间戳吗?

如上所述我甚至尝试过不可能......

3 个答案:

答案 0 :(得分:2)

当使用喜欢网址时,Facebook不提供时间。我不认为他们将来会给它。它受Facebook隐私政策的约束。

当用户喜欢url并通过ajax在数据库中插入时间时,您可以触发事件。如果用户不同并再次喜欢它,那么更新相同的记录。我之前曾通过Javascript. SDK

订阅了类似活动

您可以在文档here中找到如何订阅赞:

FB.Event.subscribe('edge.create',
    function(response) {
        alert('You liked the URL: ' + response);
        //Insert your user id with time when user liked by AJAX  
    }
);

答案 1 :(得分:2)

没有API可以返回创建Like的时间 - 相关的/<user id>/feed故事会告诉您这些信息,但并非所有Likes都有与之相关的Feed故事,并且找到故事将会非常耗时。

如果你正在使用Like Button社交插件,你可以跟踪点击Like按钮的时间,但是你还需要用户的许可才能看到他们的用户ID等,以便有效地记录它。

答案 2 :(得分:0)

我找到了解决我问题的解决方案

我依靠FQL

public static $since = '2012/01/01';
...
...

// $target1 stands for "me", it has value of my FB ID
// So I am selecting all links I liked in past year
$object_id_raw = static::$facebook->api(array(
    'method'    => 'fql.query',
    'query' => "SELECT link_id FROM link WHERE owner = {$target1} AND created_time > ".strtotime(static::$since)
));
// Just extracting IDs for later usage
$object_id = array();
foreach($object_id_raw as $oid):
    array_push($object_id, $oid['link_id']);
endforeach;

// - friendId stands for FB ID of my friends
// This query is selecting from links I liked,that means we have them liked both...
// This API call returns object ID's (ID's of links). Do whatever you want with them...
$result = static::$facebook->api(array(
    'method'    => 'fql.query',
    'query' => "SELECT object_id FROM like WHERE object_id IN ('".implode("','", $object_id)."') AND user_id = {$friendId}"
));