Facebook: Find out when user liked an URL
Asked Answered
A

3

4

I can get pair of user_id - url from url_like table.
The only two columns are, as mentioned, user_id, url.

I tried to get get date of 'liking' the URL by many ways, by connecting multiple tables, but no luck.
One of many examples might be

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

Is there any way how to get date/timestamp of when user liked particular URL?

As said I even tried impossible...

Andriette answered 16/11, 2012 at 13:49 Comment(0)
A
0

I found this solution that solves my problem

I rely on 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}"
));
Andriette answered 27/11, 2012 at 13:1 Comment(0)
B
2

Facebook doesn't offer time when use liked an URL. And I don't think they will be giving it in future. It comes under Facebook privacy policy.

You can trigger event when user liked url and insert time in your database by ajax. If user unlike and like it again then update same records. I have previously worked on subscribing like event by Javascript. SDK

You can find how to subscribe to an Like in the the documentation 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  
    }
);
Blowpipe answered 20/11, 2012 at 6:36 Comment(4)
This is exactly what my answer would be.. Its good that i read all answers before posting mine. :)Dremadremann
This does not solve problem. I want to retrieve all liked links from past. I can implement this only specific sites, not globaly...Andriette
@Andreyco: At first I told you facebook doesn't store or give you time when user liked url. So from when you will start storing that info then onwards you will be having that time info. What is mean by can implement this to only specific sites, not globally?Blowpipe
@SomnathMuluk Globaly - all sites over the world. Localy - only sites I own. I can track user behaviour only on sites I have access to! And yes, Facebook does store time when user liked the link (in different table) Solution bellowAndriette
E
2

There is no API which will return the time a Like was created - the associated /<user id>/feed story for a like will tell you this information, but not all Likes have feed stories associated with them, and finding the story will be extremely time consuming.

You could track when the Like button is clicked if you're using the Like Button social plugin, but you'd also need the user's permission to see their user ID, etc, in order to log this usefully.

Eldrida answered 20/11, 2012 at 19:41 Comment(4)
Is there any permission required to see user Id of logged in user? I haven't came across this situation until. May be I have included those permissions previously. I was assuming User ID is public. Can you please tell name of permission required to see user ID? ThanksBlowpipe
Basic permissions (i.e anyone that installs/authorises your app) will grant you access to their basic information, including ID. If they don't authorise the app, you can't find out who they areEldrida
I think we can see ID and name of any user's ID. It's public. It's not required to authorize that app. And for any other info you need permissions. Is it right? You are from Facebook. You must be knowing more than me. Correct if I am wrong.Blowpipe
You can access some basic information about any user by querying their user ID. You will not be able to determine the user id for someone browsing your website unless they have authorised your appEldrida
A
0

I found this solution that solves my problem

I rely on 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}"
));
Andriette answered 27/11, 2012 at 13:1 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.