Many of the PHP code samples in this book require the Facebook API to be included and instantiated before the sample can be run. Those precious few lines of code have been omitted throughout to save space, so stick these in when you need them:
<?php include_once 'resources/includes/config.php'; include_once 'resources/includes/facebook.php'; ?> <?php global $api_key, $secret; // Code Goes Here ?>
You’ll need to adjust the paths in the
include_once lines to match where you’ve put
the files after downloading them. See Chapter 5 for more information on setting
up your environment.
Although there’s a lot of code in here that you could lift straight off these pages and drop into your app, remember that none of this has been extensively tested as production code and there’s very little error checking. Since Facebook throws exceptions when things blow up, I’d suggest at least wrapping your code in some try/catch statements and doing something useful with your contained explosions.