|
-
June 20th, 2015, 04:03 AM
#1
[Laravel5/FB] Post links to my Facebook page as the page itself
I've got a website where users can fill a form, the web application stores the data into the database.
Those data are used to create contents on the site.
As a user submits the form, I want to post a link to the Facebook page related to the website, but not in name of the user, but as the page itself.
I've read a lot of tutorials around, but I couldn't have this working.
This is my code at the moment, but of course it doesn't work
PHP Code:
FacebookSession::setDefaultApplication($app_id, $app_secret);
$session = FacebookSession::newAppSession();
try {
$session->validate();
} catch (FacebookRequestException $ex) {
echo $ex->getMessage();
} catch (\Exception $ex) {
echo $ex->getMessage();
}
if($session)
{
try {
$response = (new FacebookRequest(
$session, 'POST', '/me/feed', array(
'link' => 'www.mysite.it',
'message' => 'some text'
)
))->execute()->getGraphObject();
echo "Posted with id: " . $response->getProperty('id');
} catch(FacebookRequestException $e) {
echo "Exception occured, code: " . $e->getCode() .
" with message: " . $e->getMessage();
}
}
What I get is this error message:
"Exception occured, code: 2500 with message: An active access token must be used to query information about the current user."
As I've understood I miss to login as the page, but I can't uderstand how to do so.
Could any one tell me how to chenge the code?
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|