0

We are trying to make Article Reader where Posting happens when user reads the Article.

The Problem we are facing is that the Article URLs are not publically available as we need to make sure the User reading the article should be logged into FB.

For instance, our Article URL is like SERVER_NAME/article/view/ARTICLE_SLUG.

Whenever any new user try to click on a post of this object, they are taken to permission page and once they allow, they are shown the article. But this Page is not scraped by facebook and hence it is not posted.

We have tried to create a Login independent URL like SERVER_NAME/article/ARTICLE_SLUG and in the og:url we set to SERVER_NAME/article/view/ARTICLE_SLUG thinking that when the posting happens it will show SERVER_NAME/article/view/ARTICLE_SLUG as the URL but its not happening.

Can someone suggest what should be the best way to do this.

2 Answers 2

1

When facebook scrapes your page they use a very specific user agent string:

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

You can read about it in the documentation for the Like Button under the "When does Facebook scrape my page?" section.

When you get a request check the user agent string in the request, if it matched the facebook scraper then allow the request and just return a simple html of just the meta and og tags. Since facebook also caches the results, it's not something that should happen more than once a day, as it says:

Facebook scrapes your page every 24 hours to ensure the properties are up to date. The page is also scraped when an admin for the Open Graph page clicks the Like button and when the URL is entered into the Facebook URL Linter. Facebook observes cache headers on your URLs - it will look at "Expires" and "Cache-Control" in order of preference. However, even if you specify a longer time, Facebook will scrape your page every 24 hours.

Sign up to request clarification or add additional context in comments.

1 Comment

Like a boss. Was looking for this for 3 hours. (Too lazy to actually monitor the requests :P )
0

Let's say your article is viewable by logged-in users at SERVER/article/view/SLUG (the view URL). Your homepage links out to a summary view of the article at SERVER/article/SLUG (the summary URL), with a button to log in which brings you to the view URL.

Your app publishes read actions at the view URL, which won't be scrapeable by the Facebook linter. In this case, you should design your app so that new traffic goes to the summary URL which, if the user is logged in already, will redirect to the view URL. The summary URL becomes the canonical URL for that article object, and you should publish actions against this URL, as it will be public.

To do this, add the metatag <og:url content="SERVER/article/SLUG" /> to both the view URL and the summary URL metadata.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.