O'Reilly logo

Facebook Cookbook by Jay Goldman

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required