Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Getting started with the Facebook PHP SDK v4.1. Example of a POST request.
try {
// Be sure to ask for the publish_actions permission first
// If you provided a 'default_access_token', third parameter '{access-token}' is optional.
$response = $fb->post( '/me/feed', [
'name' => 'Facebook API: Using the Facebook PHP SDK v4.1.x',
'link' => '',
'caption' => 'As version v4.1 of the Facebook PHP SDK nears release (at time of writing), I though this would be a good time to explain how the new version works. Migrating your application from v4.0.x to v4.1.x will break your application.',
'message' => 'Check out my new blog post!',
] );
} catch( Exception $e ) {
// catch any errors and halt script
echo $e->getMessage();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment