Jump to content
Sign in to follow this  
Kumidan

[Laravel5] Post links to my Facebook page as the page itself

Recommended Posts

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

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?

Edited by Kumidan

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.