Facebook publish stream directly using PHP

11,854

this is how I do it with PHP :

 //Note that you will need to have the access token which is what gives permission to write.
 function self_fb_post($to_uid,$acToken) {
    global $fb; //this is the fb object
    $result = false;
    $feed_dir = '/'.$to_uid.'/feed/';  //to the UID you want to send to
    $message_str =  'Why does facebook development not have decent support';
    $msg_body = array('access_token' => $acToken,   
                  'name' => 'My wall post',
                  'message' => $message_str,
                  'caption' => "www.mysite.com",
                  'link' => 'http://www.mysite.com',
                  'description' => 'A wall post which is used to express the frustration of working with crappy facebook developer documentation', 
                  'picture' => 'http://farm6.static.flickr.com/1111/some-pic.jpg',
                  'actions' => array(array('name' => 'My Site',
                              'link' => 'http://www.mysite.com'))
                  );

try {
            //this is the API call that does it all
    $result = $fb->api($feed_dir, 'post', $msg_body);
} 
catch (Exception $e) {       
    $err_str = $e->getMessage();
}


     return $result;
}
Share:
11,854
Ron
Author by

Ron

Gamer and Programer in C#, PHP, HTML, JavaScript, CSS, Ajax and Visual Basicgooglefacebook

Updated on June 04, 2022

Comments

  • Ron
    Ron almost 2 years

    I am trying to publish stream on my facebook WEBSITE wall page.

    so far I succeeded to publish stream via my APP page but I dont want via, I want to publish directly.

    as I said before, I want to publish on my facebook WEBSITE wall page, not on the app wall page.

    I couldnt find anything useful... also I want to publish with PHP if thats possible.. if it is not possible than I guess I will have to use js. anyway how can I do that?