Created
August 18, 2014 09:21
-
-
Save niraj-shah/c582890e03c19b41ec7b to your computer and use it in GitHub Desktop.
Checking if a user has liked a specific page using Facebook PHP SDK 4.0.x and Graph API 2.0+
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// 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