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

Get Marketplace Listings

Problem

I need to retrieve Marketplace listings, based on either a list of users or listing IDs.

Solution

Use the Marketplace.getListings() method:

$listings = $facebook->api_client->marketplace_getListings('1234567', null);

where 1234567 is the lid (listing ID).

If you specify no uid (user ID) as the second parameter, you’ll get the listings you’ve asked for with no filtering. You can specify a uid without lids to retrieve all the listings owned by one user:

$groups = $facebook->api_client->marketplace_getListings(null, 12345);

Both parameters can be specified as arrays as well:

$targetListings = array('1234567', '8901234');
$targetUsers = array('12345', '67890', '11223');
$listings = $facebook->api_client->marketplace_getListings
($targetListings, $targetUsers);

Discussion

Marketplace.getListings() returns a multidimensional array of listing records, with each element containing the fields listed in Table 8-13.

FQL equivalent

If you’d prefer to use FQL to access listings, the equivalent query is:

SELECT listing_id, url, title, description FROM listings WHERE poster in
 ($uids) AND listing_id in ($listing_ids)

See Table 8-13 for more information.

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