]> git.mxchange.org Git - friendica-addons.git/commitdiff
Delete the app_access_token once the addon is uninstalled. And some more error handling
authorTobias Hößl <tobias@hoessl.eu>
Sun, 18 Mar 2012 10:59:01 +0000 (10:59 +0000)
committerTobias Hößl <tobias@hoessl.eu>
Sun, 18 Mar 2012 10:59:01 +0000 (10:59 +0000)
facebook/facebook.php

index 4524a4865b18773b868257bcb073081347b4ec7f..a0fa39362b1a2179b2f631a69ca4b5fa38855b2f 100755 (executable)
@@ -75,6 +75,7 @@ function facebook_uninstall() {
        unregister_hook('plugin_settings',  'addon/facebook/facebook.php', 'facebook_plugin_settings');
        
        if (get_config('facebook', 'realtime_active') == 1) facebook_subscription_del_users();
+       del_config('facebook', 'app_access_token');
 }
 
 
@@ -150,8 +151,12 @@ function facebook_init(&$a) {
                                                        $s = fetch_url('https://graph.facebook.com/me/feed?access_token=' . $access_token);
                                                        if($s) {
                                                                $j = json_decode($s);
-                                                               logger('facebook_init: wall: ' . print_r($j,true), LOGGER_DATA);
-                                                               fb_consume_stream($uid,$j,($private_wall) ? false : true);
+                                                               if (isset($j->data)) {
+                                                                       logger('facebook_init: wall: ' . print_r($j,true), LOGGER_DATA);
+                                                                       fb_consume_stream($uid,$j,($private_wall) ? false : true);
+                                                               } else {
+                                                                       logger('facebook_init: wall: got no data from Facebook: ' . print_r($j,true), LOGGER_NORMAL);
+                                                               }
                                                        }
                                                }
                                                
@@ -1018,15 +1023,23 @@ function fb_consume_all($uid) {
                $s = fetch_url('https://graph.facebook.com/me/feed?access_token=' . $access_token);
                if($s) {
                        $j = json_decode($s);
-                       logger('fb_consume_stream: wall: ' . print_r($j,true), LOGGER_DATA);
-                       fb_consume_stream($uid,$j,($private_wall) ? false : true);
+                       if (isset($j->data)) {
+                               logger('fb_consume_stream: wall: ' . print_r($j,true), LOGGER_DATA);
+                               fb_consume_stream($uid,$j,($private_wall) ? false : true);
+                       } else {
+                               logger('fb_consume_stream: wall: got no data from Facebook: ' . print_r($j,true), LOGGER_NORMAL);
+                       }
                }
        }
        $s = fetch_url('https://graph.facebook.com/me/home?access_token=' . $access_token);
        if($s) {
                $j = json_decode($s);
-               logger('fb_consume_stream: feed: ' . print_r($j,true), LOGGER_DATA);
-               fb_consume_stream($uid,$j,false);
+               if (isset($j->data)) {
+                       logger('fb_consume_stream: feed: ' . print_r($j,true), LOGGER_DATA);
+                       fb_consume_stream($uid,$j,false);
+               } else {
+                       logger('fb_consume_stream: feed: got no data from Facebook: ' . print_r($j,true), LOGGER_NORMAL);
+               }
        }
 
 }