Question

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:

  1. Detect the referrer: Fails, the referrer is empty - maybe because FB browses the site from HTTPs?
  2. Detect client IP: Not sure about this. Does FB server have a fixed IP address?
  3. Search about a "Facebook query string" that FB uses when browses my site - something like mysite.com/?from=I'm-Facebook-Bitch: No results so far.

What do you think? Is there a reliable way to accomplish this mission? Thanks in advance.

Was it helpful?

Solution

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.

OTHER TIPS

Add a GET argument as a key to visit the website, and set a cookie once the key is found valid.

Why dont you post a 'secret' link to the 'closed' Facebook group. The link is unique, and if you visit that link you DONT need to be logged in.

Then Facebook can access without any secret voodoo magic - and the 'closed' group have access to the article.

For example:

www.example.com/articles/my-article   <- you need to be logged in to see this

www.example.com/special-hidden-link/special-hidden-article   <- no login required

So just post the "hidden link" to the Facebook group - and they can all see the article

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