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

Creating/Modifying Marketplace Listings

Problem

I need to create or modify a Facebook Marketplace listing from inside my application.

Solution

Creating and modifying listings both use the incorrectly named Marketplace.createListing() method. If you’re creating a new listing, pass a 0 for the lid (listing ID):

$attributes = array('title'=>'Bees!','category'=>'FORSALE',
'subcategory'=>'GENERAL','description'=>'Great big hive full
 of bees for sale. Makes great honey.');
$listing = $facebook->api_client->marketplace_createListing(0, true, $attributes);

If you’re modifying an existing listing, pass the listing’s lid:

$attributes = array('title'=>'Free Bees!','category'=>'FORSALE',
'subcategory'=>'GENERAL','description'=>'I\'m covered in beeeeeees!
 Please take them. Please.');
$listing = $facebook->api_client->marketplace_createListing
(23464075249, true, $attributes);

Discussion

This method (along with Users.setStatus()) requires that users grant your application an extended permission. If you call it without having the permission granted, you’ll get back a 280 error (“Creating and modifying listings requires the extended permission create_listing”). See Extended Permissions for more information on extended permissions.

The attributes array can contain settings for any of the properties of a Marketplace listing, which you can find in Listing Table.

The middle parameter is a boolean indicating whether the entry should show up on the user’s Profile. Passing true will publish a News story about the ...

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