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 ...
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.