I am trying to make this script from almost 4-6 hrs, but no luck. I have a facebook page, facebook app and facebook account. I want to code in a way that it should be able to post on my facebook page without any human interaction. I am using below code
require_once("application/libraries/facebook-php-sdk-master/src/facebook.php");
// initialize Facebook class using your own Facebook App credentials
// see: https://developers.facebook.com/docs/php/gettingstarted/#install
$config = array();
$config['appId'] = '{appid}';
$config['secret'] = '{appsecret}';
$config['fileUpload'] = false; // optional
$fb = new Facebook($config);
// define your POST parameters (replace with your own values)
$params = array(
"access_token" => "{token}",
"message" => "Here is a blog post about auto posting on Facebook using PHP #php #facebook"
);
try {
$ret = $fb->api('/mypagename/feed', 'POST', $params);
echo 'Successfully posted to Facebook';
} catch(Exception $e) {
echo $e->getMessage();
}
Using "User Access token" in API explorer i am able to post to fb page but as a "Visitor" not as admin, and if i use "App token" i get error message
{
"error": {
"message": "(#200) The user hasn't authorized the application to perform this action",
"type": "OAuthException",
"code": 200,
"fbtrace_id": "Bk30JLt+skw"
}
}
How do i add permission to post to my own facebook wall, is it even possible ?