How To: Post A Message On The User Wall Using Facebook Graph API
This is a quick post to demonstrate how to post a status message on the user wall using the Facebook Graph API. First of all, you need the publish_stream extended permission to perform this action.
Using the PHP-SDK
$args = array(
'message' => 'Hello from my App!',
'link' => 'http://www.masteringapi.com/',
'caption' => 'Visit MasteringAPI.com For Facebook API Tutorials!'
);
$post_id = $facebook->api("/me/feed", "post", $args);In the above example we posted a message and a link using the PHP-SDK.
Back to topUsing the JavaScript-SDK
This is an example of posting a message using the JavaScript SDK taken from the FB.api documentation:
var body = 'Reading Connect JS documentation';
FB.api('/me/feed', 'post', { message: body }, function(response) {
if (!response || response.error) {
alert('Error occured');
} else {
alert('Post ID: ' + response.id);
}
});
Back to topNotes
Please note that you can still post to a user wall even if the user is not connected to your application and without offline_access permission just by knowing the user id:
publish_stream:
Enables your application to post content, comments, and likes to a user’s stream and to the streams of the user’s friends. With this permission, you can publish content to a user’s feed at any time, without requiringoffline_access. However, please note that Facebook recommends a user-initiated sharing model.
$args = array(
'message' => 'Hello from app',
'link' => 'http://www.masteringapi.com/',
'caption' => 'Visit MasteringAPI.com For Facebook API Tutorials!'
);
$post_id = $facebook->api("/$USER_ID/feed", "post", $args);Back to top- Nagendra1612
- http://www.masteringapi.com Ibrahim Faour
- guest
- CC
- Wends Ang
- dbind
- nakres
- http://www.masteringapi.com Ibrahim Faour
- nakres
- http://www.masteringapi.com Ibrahim Faour
- nakres
- nakres
- http://www.masteringapi.com Ibrahim Faour
- http://www.masteringapi.com Ibrahim Faour
- Shivi_man80
- http://profiles.google.com/tom.maiaroto Thomas Maiaroto
- http://www.masteringapi.com Ibrahim Faour
- Pure Vintage Skt
- http://www.masteringapi.com Ibrahim Faour
- Nakres
- Nakres
- nakres
- Anonymous
- Wck
- http://www.masteringapi.com Ibrahim Faour
- Carolyn
- Katti Shyam
- Martin
- Vayu Sen
- Kiran BS
- Puremillions
- http://www.masteringapi.com Ibrahim Faour
- Abc
- CC
- Wends Ang
- http://www.facebook.com/people/Dionisis-Katsibas/1201230359 Dionisis Katsibas
- Alessio Somma
- Jaylenwatkins
- Praveen
- http://www.facebook.com/tantaikooi Glyn Tan Tai Kooi
- http://www.r-gate.net/ Mohamed Tair
- Prakash Malaviya
- http://www.facebook.com/true.mohsin Mohsin Khan
- http://www.facebook.com/eric.dcmd Eric Dcmd
- http://www.facebook.com/danideu Daniel Deudero
- http://www.facebook.com/profile.php?id=100005051850734 Ganesh Kumar
- http://www.facebook.com/Harshalpatil22 Harshal Patil
- sandy
Table of contents
Advertisment
Recent Tutorials
- How To: Create A User Photo Albums Browser Using Facebook Graph API
- How To: Upload A Photo To A User’s Profile Using Facebook Graph API
- How To: Check Status And RSVP To Facebook Events Using Graph API & FQL
- Facebook Javascript SDK Best Practices
- How To: Create Facebook Events Using Graph API – Advanced







