Question

I have a javascript code which adds a Facebook "Like" or "Follow" button based on a Facebook profile/page URL using the Facebook Social Plugins. I user iframes to do that, for example:

<iframe src="//www.facebook.com/plugins/follow.php?href=https%3A%2F%2Fwww.facebook.com%2Fzuck&amp;width=450&amp;height=80&amp;colorscheme=light&amp;layout=standard&amp;show_faces=true&amp;appId=276422385824711" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:450px; height:80px;" allowTransparency="true"></iframe>

If the user introduces this URL: https://www.facebook.com/pages/[name] it is added a Facebook "Like" button, because of the URL syntax (It's possible to like a FB page, but not a FB profile).

If the given URL is like https://www.facebook.com/[name], the button type will be "Follow".

But I have found some cases in which having the previous URL structure (https://www.facebook.com/[name]) it is only possible doing "like" instead of "follow".

So, which is the key/procedure to detect what type of plugin is needed? It is possible?

Thank you very much!

Was it helpful?

Solution

Pages that have a page name set can also be reached under www.facebook.com/name – so that’s no realistic way of distinguishing a user profile from a page.

Your only option would be to make an API call and look for fields that are only available on pages, but not user profiles (or the other way around) – pages have f.e. category or is_published, whereas only a user profile would have f.e. a first_name.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top