How to post on user's wall on Facebook?

How to post on user's wall on Facebook?

Hope you have already went through the tutorial on Facebook Connect implementation in Codeigniter. This is the continuation of that tutorial. Once user is authenticated with the Facebook connect, you can invoke any methods mentioned in the Facebook Graph API at http://developers.facebook.com/docs/reference/api/. Here we will explore the method, which is used to publish post a post to the user's wall on Facebook. In the previous tutorial we have created a Facebook connect library. Please add the following method to the library. If user is not logged in or has no access to post then this function will return false.


function post_to_wall($message,$link="",$photourl="") 
{
    if($this->fbSession) 
    { 
        $param = array('message'=>$message,'cb' => ''); 
        if($photourl!="") 
        { 
            $param["picture"] = $photourl; 
        } 
        if($link!="") 
            $param["link"] = $link; 
        $posts = $this->fb->api('/me/feed','post',$param); 
        return TRUE; 
    } 
    else 
    { 
        return FALSE; 
    } 
} 

Similarly if you want to retrieve all the posts in the user's wall, then use "me/home" instead of "me/feed" in the above function. Learned something? For complete reference of the available functions refer the Facebook Graph API.

Website in minutes

Do you know that you can generate a complete PHP websites in minutes with PHP Website Generator?

Features

  • Free admin dashboard
  • Role based security
  • Login with Facebook, Google and more
  • Queue based email processing
  • Price at $3 for website
  • Uses CodeIgniter framework

Generate website now See Pricing



Connect with Google or Facebook and generate your next CodeIgniter website in minutes with plenty of features like searching with pagination, AJAX based grid data editors, group based security and admin portal etc.