I have this closed-beta website that disables normal visits - visitors have to log in first to view the site. I have a secret Facebook group also, in which we often share the links to the website articles (for discussion). Problem is, when we paste a link, Facebook tries to get its preview and fails, since it's considered a non-logged in user. So in short, I'd want the website is public only to Facebook. These are the solutions I've come up with:
What do you think? Is there a reliable way to accomplish this mission? Thanks in advance.
OK I've found the solution here: https://developers.facebook.com/docs/reference/plugins/like/
Instead of checking for IP or referrer, we can check for the user agent ($_SERVER['HTTP_USER_AGENT']
) of the FB scraper. The value is facebookexternalhit/1.1 (+http://www.facebook.com/externalhit_uatext.php)
Hope it helps someone else.