Last Updated: February 25, 2016
·
6.373K
· pleone

Facebook - how to easy post to wall

Very easy setup for publishing a post with a facebook app.
This is written symfony 1.4 like, but can easily adopted for any kind of framework (or PHP plain too )

  1. Download and include ( https://developers.facebook.com/docs/reference/php/ )
  2. Create a facebook app and setup facebook login ( out of topic of this protip )
  3. Let's initialize facebook api:

    $options = array(
    'appId' => sfConfig::get('app_facebook_app_id', null),
    'secret' => sfConfig::get('app_facebook_secret', null),
    );  
    $facebook = new Facebook($options);
  4. Let's call the api:

    $facebook->api("/me/feed" , "post" , array(
        "message" => "Wonderful message",
        "link" => "http://wonderful.link",
        "picture" => "http://wondeful.link/wonderful.image.png",
        "name" => "Check this out!",
        "caption" => "The coolest app on the Earth. Maybe on the Moon too",
        "description" => "What are you waiting? Let's do it now. Let's kill the Purple Tentacle!" ,
    ));
  5. Check your wall. You're done!