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.

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.