I know this has been asked and answered before, but I can't find any answers that are for the newer Facebook v2.3 API.
I've set up the script to post to a managed page I am an administrator to, I've got my graph api all working and I can post to my own timeline with no problems, but posting to a managed page I appear to be posting it as me posting to another page:
Jim shared a link to Awesome Company's Timeline.
What I'm really trying to do is post as the page.
Does anyone know how to do this in the new API?
Here's a snip of my code so far:
$page_id = xxxxxxxxxxxxxxx;
$access_token = (new FacebookRequest( $session, 'GET', '/' . $page_id, array( 'fields' => 'access_token' ) ))
->execute()->getGraphObject()->asArray();
// save access token in variable for later use
$access_token = $access_token['access_token'];
$page_post = (new FacebookRequest( $session, 'POST', '/'. $page_id .'/feed', array(
'access_token' => $access_token,
'name' => 'A Name',
'link' => 'http://www.example.com',
'caption' => 'Testing the facebook api',
'message' => 'Check out our latest news post!',
) ))->execute()->getGraphObject()->asArray();
// return post_id
print_r( $page_post );