1

i wonder if there's any way to determine, if a given ID is a user, group or page on facebook. I've checked the FQL-Reference, but haven't found anything.

EDIT:

Nevermind. It seems, that ?metadata=1 does the trick (if the profile is accessible)

1 Answer 1

3

As far as i'm aware, there is no way to simply get a "type" back from facebook, as they assume you know what the ID is supposed to relate too anyway.

The best thing i can think of is to find an attribute which is unique to each object, and check if it exists on the returned data from

://graph.facebook.com/id

You will want to check the documentation and return data for the best key/attribute to check, but from a quick look at the docs, you could possible check:

  • If company exists, assume its an application id
  • If first_name exists, assume its a user id
  • If owner exists, assume its a group

The advantage being that once you determine the type of the ID, you already have the data you need for the object, to do whatever consequent actions.

N.B: The fact you don't know the type, leads me to believe that you don't have any access_token which will allow you additional permissions. Therefore you're restricted to public data, so be sure to use a key that does not require an access_token (i.e. i haven't tested this, but what gets returned from a group ID object, when a group is private? Owner may not be available and you may need to test for other keys, or allow for variations)

2
  • Thanks. I use the access token of my application. The result is different from a users access token, but it provides enough informations to fit my needs. Aug 13, 2013 at 10:29
  • Okay, i guess i found a way. See the initial post. Aug 13, 2013 at 10:48

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.