Post on user wall in Facebook

A tutorial on making post on user's wall using Facebook Graph API.

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.

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 $5 for website
  • Uses CodeIgniter framework

Generate website now See Pricing



You can generate an entire website in CodeIgniter using our PHP Website Generator using easy to use wizards. PHP Website Generator provide many features including search with pagination, AJAX based grid data editors, Group based security and free Admin dashboard etc. Please connect with Google or Facebook and to generate your CodeIgniter website in minutes.