Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

OpenGraph API User Object Sometimes Returns Link that 404s

In my application I allow users to connect their Facebook accounts via oauth for the purpose of posting via our interface. We support both page accounts and regular accounts that simply manage pages.

We also inspect the result of the opengraph API call to get a valid URL to their profile, or page. The primary endpoint we use is https://graph.facebook.com/me (with oauth credentials). For some page-only accounts, the returned object has a 'link' value that, when entered into a web browser, 404s.

The bad URLs I have seen fall into two distinct cases:

The URL can be of the form 'www.facebook.com/{page_id}' which 404s on some pages, but not others.

The URL can be of the form 'www.facebook.com/profile.php?id={user_id}' which more often than not 404s.

The only URL format I have seen that works for all accounts is www.facebook.com/profile.php?id={page_id}. In the first case, we detect that the 'link' field isn't of the proper form (using profile.php?id=...), and construct a URL with the proper structure, and it works.

My next heuristic I'm considering adding is to see if the URL is of the proper form....but uses the {user_id} as the id argument to profile.php, and just construct the URL using the {page_id}. Obviously, this is getting ridiculous.

So, is there a good way to know if an account will give back a link that is invalid? Is this a bug in the API? What is the most reliable way to, given a User on the open graph API, to get a working link to their profile/page?

like image 362
Ryan Gee Avatar asked Jan 04 '13 23:01

Ryan Gee


1 Answers

Using 'www.facebook.com/{page_id}' or 'www.facebook.com/profile.php?id={user_id}' will always work - they are both the same. The only reason you'll see a 404 is if the Page has been unpublished / deleted or if the user has deactivated their account.

like image 182
Niraj Shah Avatar answered Oct 21 '22 12:10

Niraj Shah