Skip to content

Instantly share code, notes, and snippets.

@e0ipso
Last active January 14, 2016 08:36
Show Gist options
  • Select an option

  • Save e0ipso/6256131 to your computer and use it in GitHub Desktop.

Select an option

Save e0ipso/6256131 to your computer and use it in GitHub Desktop.
Use FBAutopost wrapper class to publish to a fan page.
<?php
try {
$fb = facebook_autopost();
$fb
->setDestination($facebook_page_id)
->publish(array(
'type' => 'status',
'params' => array('message' => t('Hello world.')),
));
}
catch (ErrorException $e) {
drupal_set_message($e->getMessage(), 'error');
}
?>
@drasgardian

Copy link
Copy Markdown

This should call the factory function facebook_autopost() instead of instantiating FBAutopost directly.

@singhsurma

Copy link
Copy Markdown

Can we get response of post as well like exception errors, such as I need Link to Facebook page of the recent gone post. Please suggest!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment