We have already told you how to programmatically post to an user's Facebook Wall via Graph API and CURL and without using PHP-SDK. Well, In this article we will show you how to build and attachment for the Facebook Wall Post and post it to any user's Facebook wall using the PHP-SDK and the Graph API.
Please not that in order to post something on any user's Facebook wall, you will need to ask the user for the publish_stream extended permission. Wall posts can be easily made by issuing a POST request to a Facebook User's wall feed with the required attachment variable. Check this working code snippet below for more details.
We have assumed that you have already initialized the Facebook object. If not, then find out How to initialise a Facebook Object using PHP-SDK.
How to find out if the Wall Post was successful?
In the above code snippet, the variable $result contains the Facebook ID of the wall post you just made in the following format:
So, if the logged in user's Facebook id is 12345678 and the id of the wall post is 987654321, then the function's return value would be:
So, in order to find out if the wall post was successful, you can search for the logged-in user's Facebook ID in the return value using the PHP function strpos(). A TRUE value would imply that the wall post was successful.
If you are facing any problem with the implementation do write to me at: firstname.lastname@example.org. You can also hire me for developing Facebook applications for you.
Related Posts by Tags: Facebook, graph, graph api, php-sdk, post, programmatically, user, wall