Site icon Web Niraj

Let Facebook Scrape Password Protected Pages for Like Buttons

If you have various password protected pages on your website, but want people to Like your pages (via Facebook), there is a simple trick you can use to allow this. You can detect the Facebook Scraper by its User Agent and serve up an alternative page that contains the OpenGraph markup you would like to use.

In PHP the code would look something like:

See the gist on github.

The User Agent from Facebook is:

facebookexternalhit/1.1 (+https://www.facebook.com/externalhit_uatext.php)

 

Exit mobile version