Possible Duplicate:
Facebook Graph Api - Posting to Fan Page as an Admin
I am trying to have a form on my site where I can submit a blog post and then send that same blog post to my page on facebook.
My page is: https://www.facebook.com/foreveraloneminecraft
I want it to post it as if I was logged in and manually posted (like all the other posts on there).
I have been searching all over the place and everything I find either never actually posts something or throws an error.
This is what I got so far after searching all over:
<?php
include('core/init.inc.php');
require_once('libs/parser.php'); // path to Recruiting Parsers' file
$parser = new parser; // start up Recruiting Parsers
if(isset($_POST['submit'], $_POST['user'], $_POST['title'], $_POST['body'])
{
//--- Facebook Posting ------
require_once('libs/facebook/facebook.php');
$appid = '286964398044671';
$appsecret = 'myappsecret';
$pageid = '215852885143861';
$token = 'mytoken';
// Create our Application instance (replace this with your appId and secret).
$facebook = new Facebook(array(
'appId' => $appid,
'secret' => $appsecret,
));
// Get the current access token
//$token = $facebook->getAccessToken();
//Information that makes up the facebook page post
$attachment = array(
'access_token' => $token,
'message' => $_POST['body'],
'link' => 'http://hgs1957.hostedd.com/news.php',
'picture' => 'http://hgs1957.hostedd.com/images/foreverAloneMCguy.png',
'name' => $_POST['title'],
'description'=> 'Latest news for foreveralonemc.com.'
);
//Try to post to the facebook page
try{
$res = $facebook->api('/'.$pageid.'/feed','POST',$attachment);
} catch (Exception $e){
echo $e->getMessage();
}
//Add the post to the sql database of posts
//add_post($_POST['user'], $_POST['title'], $_POST['body']);
//Redirect to news feed
header('Location: news.php');
die();
}
?>
I used the appsecret from the token is that I got when using https://developers.facebook.com/tools/explorer/ with the permissions: publish_stream, status_update, manage_pages, publish_actions, offline_access After trying that it seems to post to the page wall but as me not as the page or admin.
Anyone know if this is just a bug or what I am doing wrong?