Since notifications are not available in the Facebook Graph API, I am using FQL to retrieve them, as detailed at https://developers.facebook.com/docs/reference/fql/notification/.
What I would like to do is use the information returned to fetch the “source object”. So if the notification is “Bob commented on your status”, I want to find that status object – and if Bob comments on my Note, or posts to the Wall for my Event, etc.
notification_id, sender_id and recipient_id alone don’t seem to be enough information to achieve this. The href field is tantalisingly close – it’ll return a link that a user can click on to be taken to the appropriate page, but that doesn’t look like much help to me as the URL format varies wildly between “source object” types. I can’t find a reliable way to turn href into a parameter I can pass to the Graph API.
So, if what I want to do is possible, what’s the best way to do it?
My thoughts:
-
Is there a way to give the “user-friendly”
hrefto an API and have it return the appropriate Graph API results (or have it return the appropriate Graph API URL)? -
Is there another way the information returned by an FQL ‘notification’ query can be used or combined to make a proper Graph API URL?
-
Is there another way of retrieving notifications that will give me what I want?
I’m using PHP and Facebook’s PHP SDK, though this doesn’t look like a PHP-specific issue.
Thanks in advance!
You can get
object_id,object_typefrom thenotificationtable and use that to fetch the original post. Sorry, this wasn’t documented in the ‘notification’ table, but is documented now.E.g.:
select object_id, object_type from notification where recipient_id=<user_uid>which returns something like:
and you can then use the object_id to fetch the post: