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

Setting Status

Problem

I need to set the Facebook status of my users.

Solution

Use the Users.setStatus() method, which unfortunately isn’t supported in the PHP Client Library (see Adding Missing PHP Client Library Methods):

$result = $facebook->api_client->Users_setStatus('setting his status
using the API!',false);

The parameters, in order, are the status and whether or not to clear the status. Passing true for clear will ignore the status you pass in and leave it blank.

Discussion

You can set the status only for users who have given your application the status_update extended permission (see Extended Permissions for more information).

Users.setStatus() will also accept two additional parameters: a boolean called status_includes_verb, which will prepend “is” to the front of your status if you pass false, and a uid of the user for which you want to set the status (which is ignored for desktop apps and is required for web apps only if you don’t have a valid session).

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