0

Its a reveal page app and

The app check if the user likes the fanpage through signed_request, if not it shows an image that says like us, else it shows the content to the fan.

This works fine when someone comes to the fanpage i.e. app is running within the fanpage as a tab. e.g. http://www.facebook.com/myfanpage?sk=app_xxxxxxxxxxxxxx

If someone comes to the app directly e.g. http://apps.facebook.com/myappname it always shows the image that says like us whether user already likes or not.

Is there a way to check how the app is being accessed? directly or as a tab in the fan page? I can not use 'top.location.href' in javascript, it returns null I guess because of obvious reasons of cross domains, i.e. app is running from some other domain and not on facebook.

Regards

practitioner
  • 43
  • 2
  • 7
  • The signed request is sent in a POST request on the page tab, so you can detect that easily enough, if your app is loaded as a canvas app (incidentally, why are you doing that?) instead of on the page tab, you'll need permission from the user to check their likes unless their likes are public – Igy Feb 20 '12 at 17:34
  • :) yeah, if I've the signed request the user came through the page tab, simple. Thanks – practitioner Feb 21 '12 at 04:44
  • @Igy I just checked, if you access directly, you get the signed request, but not the page like info. if($signed_request = parsePageSignedRequest()) { if($signed_request->page->liked) { – practitioner Feb 21 '12 at 04:57

1 Answers1

0

You can use the Facebook JavaScript SDK to call the Graph API URL in the form https://graph.facebook.com/PROFILE_ID/likes/PAGE_ID and see if the user likes your page.

See this link for documentation: http://developers.facebook.com/docs/reference/api/user/#likes

derickito
  • 695
  • 7
  • 25