Is it possible to display the Facebook Like button only if the user is logged into Facebook?
1 answer
Yes and no. This is possible if your facebook app is not showing in the tab because there is no javascript in the facebook tab and no user information is passed until the user clicks somewhere.
If you are writing a "real" facebook application you can try the following code, I am doing it in PHP like this:
// Get user id
public function getUserId()
{
$user_id = 0;
try
{
$user_id = $this->facebook->api_client->users_getLoggedInUser();
}
catch(Exception $e)
{
$user_id = 0;
}
return $user_id;
}
If this code returns "0", the guest is viewing the application.
+2
a source to share