Better err handling when trying to get Facebook client

This commit is contained in:
Zach Copley 2009-05-15 21:44:58 +00:00
parent 41f6c9d8cf
commit a0320f03f5
1 changed files with 13 additions and 2 deletions

View File

@ -27,9 +27,21 @@ define("FACEBOOK_PROMPTED_UPDATE_PREF", 2);
function getFacebook()
{
static $facebook = null;
$apikey = common_config('facebook', 'apikey');
$secret = common_config('facebook', 'secret');
return new Facebook($apikey, $secret);
if ($facebook === null) {
$facebook = new Facebook($apikey, $secret);
}
if (!$facebook) {
common_log(LOG_ERR, 'Could not make new Facebook client obj!',
__FILE__);
}
return $facebook;
}
function updateProfileBox($facebook, $flink, $notice) {
@ -92,7 +104,6 @@ function isFacebookBound($notice, $flink) {
}
function facebookBroadcastNotice($notice)
{
$facebook = getFacebook();