Facebook: Find out when user liked an URL

前端 未结 3 1232
梦如初夏
梦如初夏 2021-01-19 09:37

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

3条回答
  •  南方客
    南方客 (楼主)
    2021-01-19 10:07

    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}"
    ));
    

提交回复
热议问题