Web Niraj
  • Facebook
  • Flickr
  • Github
  • Google+
  • Linkedin
  • Twitter
  • YouTube
Online portfolio, code examples and developer blog
  • Home
  • About Me
  • Contact Me
  • 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:

The User Agent from Facebook is:

facebookexternalhit/1.1 (+https://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

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

Support me via Patreon

Become a Patron!

StackExchange / StackOverflow

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

Tags

Amazon Web Services Android Android 4.4 KitKat Android 5.0 Lollipop Apache API Application Backup Bug Command Line Cordova Example Facebook Facebook Graph API Facebook PHP SDK 4.0 Facebook Social Plugins Fan Page Flash Geolocation Google Nexus 5 Google Nexus One Hacking HTML5 Image Manipulation iOS iPhone JavaScript jQuery Laravel 5 Linux NodeJS Parse PDF PHP Plugin Portfolio Security Server SSH SSL Sysadmin Tutorial Wonga.com WordPress WordPress Plugins
© 2011-2019 Niraj Shah
  • Privacy Policy
We use cookies to ensure that we give you the best experience on our website. If you continue to use this site we will assume that you are happy with it.OkPrivacy Policy