Skip to content

Instantly share code, notes, and snippets.

@ducan-ne
Last active January 11, 2017 05:09
Show Gist options
  • Save ducan-ne/0ef22255b89754369fe08e8dfe6b1591 to your computer and use it in GitHub Desktop.
Save ducan-ne/0ef22255b89754369fe08e8dfe6b1591 to your computer and use it in GitHub Desktop.
const _TOKEN = '<MY TOKEN>';
$response = _GRAPH('/364997627165697/feed/',array('limit' => 30, 'fields' => 'id'));
array_walk($response['data'], function(&$data) use($GLOBALS){
extract($data);
if((time() - strtotime($updated_time)) > 5 * 60){ // 5 = 5 minute
return $data = [
'liked' => _GRAPH("/{$id}/likes/",array('method' => 'POST'))
// _GRAPH("/{$data->id}/sharedposts/",array('method' => 'POST', 'privacy' => json_encode(["value" => "SELF"])))
];
}else{
return [];
}
});
print_r($response);
function _GRAPH($path,$params){
return json_decode(@file_get_contents('https://graph.facebook.com'.$path.'?'.http_build_query(array_merge($params,array('access_token' => constant('_TOKEN'))))),true);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment