Online Book Reader

Home Category

Facebook Cookbook - Jay Goldman [151]

By Root 715 0
. '"> '

. $subcategory . '';

}

}

}

echo '';

}

Deleting Marketplace Listings


Problem


I need to delete a Marketplace listing.

Solution


Use the Marketplace.removeListing() method:

$result = $facebook->api_client->marketplace_removeListing('1234567');

You can optionally specify a status to make it clear why the listing is being removed. Valid statuses are SUCCESS, DEFAULT, or NOT_SUCCESS (the default is, unsurprisingly, DEFAULT):

$result = $facebook->api_client->marketplace_removeListing('1234567', 'SUCCESS');

Discussion


You can also tag a uid on the end to specify whose listings you’re deleting if they are not the current loggedinuser (this will be ignored for desktop apps). Marketplace.removeListing() will return true (1) on success, and false (0) or an error on failure.

Searching the Marketplace


Problem


I need to search the Marketplace.

Solution


Use the Marketplace.search() method:

$results = $facebook->api_client->marketplace_search(null, null, 'donuts');

The first two parameters are optional category and subcategory filters:

$results = $facebook->api_client->marketplace_search('JOBS', null, 'donuts');

Discussion


Marketplace.search() returns a multidimensional array in which each element is a listing containing the fields found in Table 8-13 in Listing Table.

Sending Notifications


Problem


I need to send Notifications out to my users and their friends.

Solution


Use the Notifications.send() method to send on-Facebook Notifications:

$to_ids = array('12345', '67890');

$result = $facebook->api_client->notifications_send($to_ids,

'Your super disco nap is over! Time to wake up!');

You can send a Notification to the current loggedinuser by passing an empty string for to_ids. If you send the Notification to other users, make sure that the content starts with a verb because Facebook will prepend your text with the user’s name (e.g., “Jay Goldman...”). The prepending doesn’t happen if you send the Notification to the current loggedinuser.

The second parameter is the actual content for the Notification and allows for some FBML and markup, so you can experiment to find out what’s allowable. Notifications.send() returns a comma-separated list of the users it was able to send the Notification to.

Use the Notifications.sendEmail() method to send off-Facebook Notifications:

$recipients = array('12345', '67890');

$subject = 'Hello Disco Nappers!';

$text = 'This is a reminder that it\'s almost time for you to take your

next Disco Nap!';

$fbml = 'This is a reminder about your forthcoming Disco Nap with

!';

$result = $facebook->api_client->notifications_sendEmail($recipients,

$subject, $text, $fbml);

Every application has an imposed limit on the number of emails you can send per day, which you can find in your Facebook Insights application, on the Allocations tab (see http://www.new.facebook.com/business/insights/app.php?id=12345&tab=allocations, where 12345 is your app’s ID). Desktop apps have to pass a session key and can send email only to the current user identified in that session. Some tags are prohibited in the fbml parameter, so try experimenting to see what you can get away with. Notifications.sendEmail() returns a comma-separated list of the users it was able to send the Notification to.

Discussion


Notifications have got to be one of the most contentious issues for Facebook app developers. On the one hand, they make up the bread and butter of how a lot of applications grow their user bases. On the other hand, they’re the pain in the inbox that users most often lament when complaining about how Facebook applications are ruining their Facebook experience. We’ve all logged in to find an overwhelming avalanche of Notifications, but we’re also tickled pink when we find out that it’s our turn in a Scrabulous game or that someone has stolen our Two Headed Serpent in PackRat.

Notifications are a mechanism for your application to alert your users that something has

Return Main Page Previous Page Next Page

®Online Book Reader