Facebook Application Development – Publishing to the Wall
Its very easy to publish stream via Facebook, let’s post something to the wall after verifying the user has the publish_stream permission
- # let’s check if the user has granted access to posting in the wall
- $api_call = array(
- ‘method’ => ‘users.hasAppPermission’,
- ‘uid’ => $uid,
- ‘ext_perm’ => ‘publish_stream’
- );
- $can_post = $facebook->api($api_call);
- if($can_post){
- # post it!
- $facebook->api(‘/’.$uid.‘/feed’, ‘post’, array(‘message’ => ‘Saying hello from my Facebook app!’));
- echo ‘Posted!’;
- } else {
- die(‘Permissions required!’);
- }
Essentially, we are making an API call to //feed, using the POST method (second argument) and an array as a third argument for the data to be sent. In this case, this third argument supports message, link, picture, caption, name and description. Here’s the code:
- $facebook->api(‘/’.$uid.‘/feed’, ‘post’, array(
- ‘message’ => ‘The message’,
- ‘name’ => ‘The name’,
- ‘description’ => ‘The description’,
- ‘caption’ => ‘The caption’,
- ‘picture’ => ‘http://i.imgur.com/yx3q2.png’,
- ‘link’ => ‘http://net.tutsplus.com/’
- ));
Here’s how it is posted.
Follow @phpzag

