Web Niraj
  • Facebook
  • Flickr
  • Github
  • Linkedin
  • Twitter
  • YouTube
Online portfolio, code examples and developer blog
  • About
  • Contact
  • Portfolio
  • WordPress
Search the site...
  • Home
  • Blog
  • Let Facebook Scrape Password Protected Pages for Like Buttons

Let Facebook Scrape Password Protected Pages for Like Buttons

4

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:

https://gist.github.com/niraj-shah/8029713

The User Agent from Facebook is:

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

 

Facebook, Tutorial

4 comments on “Let Facebook Scrape Password Protected Pages for Like Buttons”

  1. Rui miguel says:
    December 18, 2013 at 5:47 PM

    Hi,
    Your solution it´s not working for me.
    I´m trying to share custom content but i always get the Open Graph error 200, it doesn´t bypass the custom login system.

    Any ideias?

    Regards,

    Reply
    • Niraj Shah says:
      December 18, 2013 at 9:00 PM

      This has nothing to do with OpenGraph API calls. If you noticed, no Ope Graph API calls are bring made in the code. It’s purely to detect if Facebook is scraping your pages for content. Sharing content is covered in another article on my blog – please refer to that.

      Reply
      • Rui miguel says:
        December 19, 2013 at 10:31 AM

        Thank you for the reply,
        I read your article but not sure how can i share content if there´s a custom login system, that is my big problem.

        Regards,

      • Niraj Shah says:
        December 19, 2013 at 11:01 AM

        You need to use the code in this article together with the code in the “Facebook API: Posting a Status Update” article.

Leave a Reply to Niraj Shah Cancel reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

StackExchange / StackOverflow

profile for Niraj Shah on Stack Exchange, a network of free, community-driven Q&A sites

Support Me

PSN Profile

Tags

ACL Amazon Amazon Web Services Android Android 4.4 KitKat Android 5.0 Lollipop Apache Backup Bug Command Line Cordova cPanel / WHM Facebook Facebook Graph API Facebook PHP SDK 4.0 Facebook Social Plugins Fan Page Firewall Flash Gadget Geolocation Google Nexus 5 Hacking HTML5 iOS JavaScript jQuery Laravel 5 Linux NodeJS Parse PDF PHP Plugin Portfolio PS4 Review Security Server SSH SSL Sysadmin Tutorial WordPress WordPress Plugins
© 2011-2025 Niraj Shah
  • Blog
  • Portfolio
  • WordPress
  • About Me
  • Contact Me
  • Privacy Policy