Skip to content

Instantly share code, notes, and snippets.

@bmarshall511
Last active August 29, 2015 14:05
Show Gist options
  • Select an option

  • Save bmarshall511/952edbe8a3c56d5353cc to your computer and use it in GitHub Desktop.

Select an option

Save bmarshall511/952edbe8a3c56d5353cc to your computer and use it in GitHub Desktop.
<?php
use Facebook\FacebookRequest;
/**
* Publish to User’s Timeline
*/
// Graph API to publish to timeline
$request = (new FacebookRequest( $session, 'POST', '/me/feed', array(
'message' => 'I love articles on benmarshall.me!'
)))->execute();
// Get response as an array, returns ID of post
$response = $request->getGraphObject()->asArray();
print_r( $response );
// Graph API to publish to timeline with additional parameters
$request = (new FacebookRequest( $session, 'POST', '/me/feed', array(
'name' => 'Facebook SDK PHP v4 — a complete guide!',
'caption' => 'Learn how to easily use the Facebook SDK PHP v4 library.',
'link' => 'http://www.benmarshall.me/facebook-sdk-php-v4',
'message' => 'Check out how to integrate Facebook with your website.'
)))->execute();
// Get response as an array, returns ID of post
$response = $request->getGraphObject()->asArray();
print_r( $response );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment