Retrieving a Listing
Problem
I need to retrieve specific a listing from the Facebook Marketplace using FQL.
Solution
If you know the listing_id
of
the listing, it’s as simple as:
SELECT url, title, description, price, poster FROM listing WHERE listing_id = $listing_id;
If you don’t know the listing_id
but it was posted by user
and you do know the title
, you can do:
SELECT listing_id, description FROM listing WHERE title = $title AND poster = $user;
Discussion
The current loggedinuser
needs to be allowed to see the specified listing or you’ll get back an
empty set. Two things to note if you’re looking up a listing by
title:
Listings aren’t unique by title, so you may well get more than one result back.
Remember that it’s an exact match, so you’ll need to get punctuation and capitalization exactly right.
Get Facebook Cookbook now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.