It\'s final try with PHP, if it fails, I\'ll try with JS. So my goal is to post on FB page as \"Page name\" through PHP: this is what I want to get
I struggled with this most of the day, then found that not using setAccessToken(page_access_token) was the only thing preventing it from working for me. I found that in a stackoverflow post from 18 months ago. I'll put my solution here, for anyone who has this question in the future:
protected $scope = "email,publish_stream,manage_pages";
$url = "{$api_url}/{$fbusername}/accounts?access_token=".$access_token;
$response = json_decode(file_get_contents($url));
foreach($response->data as $data) {
try
{
$res = $this->SDK->setAccessToken($data->access_token);
$res = $this->SDK->api(
"{$data->id}/feed",
"POST",
array('link' => 'www.example.com',
'message' => 'This is a test message from php',)
);
log::debug(__FUNCTION__, print_r($res,true));
}
catch (Exception $e)
{
log::debug(__FUNCTION__, $e->getType().": ".$e->getMessage());
}
}