2

Is there is any way of checking if the user is connected to facebook on my external page without having them to allow one of my applications? And the same question goes for "check if the user liked a page".

I have checked around 20 questions and 3-4 tutorials and seems like all of them are talking about internal scripts (tabs inside a fanpage/apps canvas pages) and my question is directed only to EXTERNAL pages.

If it is possible, please shout here a code example (PHP+JavaScript). Thanks!

Ricardo
  • 1,653
  • 8
  • 26
  • 51

3 Answers3

2

You can check if there is a facebook session using javascript sdk:

<script type="text/javascript" src="http://connect.facebook.net/es_ES/all.js"></script>
<script type="text/javascript">
   FB.init({
         appId  : 'your app id',
         status : true, // check login status
         cookie : true, // enable cookies 
         xfbml  : true  // parse XFBML
    });     
    FB.getLoginStatus(function(response) {
          console.log(response) // See other useful information on JavaScript console.
          console.log(response.status) // Show if the user is connected with facebook or not
          if (response.session) {
              // session found do something
          } else {
              // no user session available
          }
     });
</script>

Hope it will help.

Ish
  • 28,486
  • 11
  • 60
  • 77
sken boy
  • 137
  • 2
  • 11
0

How do I know when a user clicks a Like button?

If you are using the XFBML version of the button, you can subscribe to the 'edge.create' event through FB.Event.subscribe.

Check whether users is logged into facebook:

Check if user is logged in New Facebook API

Community
  • 1
  • 1
Tarik
  • 79,711
  • 83
  • 236
  • 349
  • Oh, so basically if the user has already liked the page the like button won't be showed? – Ricardo Jun 25 '11 at 22:39
  • You can subscribe your callback function so after users click on the like button, callback functions will be invoked. – Tarik Jun 25 '11 at 22:44
0

No this is not possible from an external page. You can use javascript and subscribe to the event when they do like a page, but you won't know a head of time if they already like your page. They would need to authenticate your application and then you could execute an FQL query to verify.

bkaid
  • 51,465
  • 22
  • 112
  • 128
  • Thanks buddy, so the same thing goes with "are they logged into facebook"? basically i want to show a like button if they are connected and if they not i want to put an email autoresponder form. – Ricardo Jun 25 '11 at 22:43