iamkhush
iamkhush

Reputation: 2592

Implementing metatags for open graph

Facebook needs the url of the object when sending a action post request. Now , my app only allows authorized users, I redirect the user to the login page and it redirects back to the user requested page.

But how do I differentiate between fb trying to access the metatags(while posting) or users coming from fb whom I have to redirect ?

Upvotes: 2

Views: 455

Answers (2)

iamkhush
iamkhush

Reputation: 2592

The problem was to differentiate between a Facebook crawler and a user.

I don't remember the exact thing I wrote, but the general idea was that facebook parser just reads the html head tags . I added a fb redirect which sends the authenticated user to the desired page . This redirect wouldnt affect the crawler because javascript isnt executed by a crawler.

Now , since my need was to allow only authenticated users to go ahead, the FB js api handled auth as well. :)

Do tell me , if you need to know the specific fb api call.

Upvotes: 0

Juicy Scripter
Juicy Scripter

Reputation: 25918

You missed some concepts behind of OpenGraph. All objects should have a publicly accessible representing page.

Citing Publishing Objects section from Facebook's OpenGraph Objects documentation:

Open Graph Objects are simply your web pages with Open Graph meta tags. Before you can publish an Open Graph object, you must define its corresponding object type in the Open Graph section of the Developer App. Once you have defined your object type in the tool, you must create a publicly accessible web page that represents your object using Open Graph metatags. We provide boilerplate metatags that you can use to create this web page in the Developer App (click the Get Code link next to your object definition). With these tags in place, you can publish actions that refer to your object.

When Facebook sees the first action applied to your object, we will scrape your page, read its meta tags and connect the user to your object, via the action. Every 7 days after the initial scrape of your object, we will attempt to re-scrape your object to keep the object data up to date.

Upvotes: 2

Related Questions