Skip to content

Instantly share code, notes, and snippets.

@niraj-shah
Created February 19, 2015 18:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save niraj-shah/56bf50740a973950970d to your computer and use it in GitHub Desktop.
Save niraj-shah/56bf50740a973950970d to your computer and use it in GitHub Desktop.
Getting started with the Facebook PHP SDK v4.1. Example of a POST request.
<?php
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' => 'https://www.webniraj.com/2015/02/19/facebook-api-using-the-facebook-php-sdk-v4-1-x/',
'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();
exit;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment