<card>
# Post Links Using the Graph API

This example covers posting a link to the current user's timeline using the Graph API and Facebook SDK for PHP.

It assumes that you've already set your default app id and secret, and acquired a `FacebookSession` using an access token or one of the login helper classes found [here](/docs/php).  You must have requested the `publish_actions` scope when logging in the user for this to work.

For more information, see the documentation for [`GraphObject`](/docs/php/GraphObject), [`FacebookRequest`](/docs/php/FacebookRequest), and [`FacebookRequestException`](/docs/php/FacebookRequestException).

</card>

<card>

~~~~
use Facebook\FacebookRequest;
use Facebook\GraphObject;
use Facebook\FacebookRequestException;

if($session) {

  try {

    $response = (new FacebookRequest(
      $session, 'POST', '/me/feed', array(
      	'link' => 'www.example.com',
      	'message' => 'User provided message'
      )
    ))->execute()->getGraphObject();

    echo "Posted with id: " . $response->getProperty('id');

  } catch(FacebookRequestException $e) {

    echo "Exception occured, code: " . $e->getCode();
    echo " with message: " . $e->getMessage();

  }   

}
~~~~

Note that the 'message' field must come from the user, as pre-filled content is forbidden by the [Platform Policies](https://developers.intern.facebook.com/policy/#control) (2.3).

</card>