]> git.mxchange.org Git - quix0rs-gnu-social.git/commitdiff
Better err handling when trying to get Facebook client
authorZach Copley <zach@controlyourself.ca>
Fri, 15 May 2009 21:44:58 +0000 (21:44 +0000)
committerZach Copley <zach@controlyourself.ca>
Wed, 27 May 2009 00:01:39 +0000 (00:01 +0000)
lib/facebookutil.php

index ec39872732fa45ae22ed95c88f4f3b34633ee28f..242d2e06f280e1bd0bbe6587d2ece54b7ab1dd04 100644 (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();