Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Checking if a user has liked a specific page using Facebook PHP SDK 4.0.x and Graph API 2.0+
// get like status
$liked = (new FacebookRequest( $session, 'GET', '/me/likes/' . $page_id ))->execute()->getGraphObject()->asArray();
// if $liked return array with at least one result, user has liked the page
if ( isset( $liked ) && count( $liked ) > 0 ) {
echo '<h2>Liked</h2>';
} else {
echo '<h2>Not Liked</h2>';
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment