]> git.mxchange.org Git - friendica-addons.git/commitdiff
Merge with main branch
authorTobias Hößl <tobias@hoessl.eu>
Tue, 17 Apr 2012 08:47:48 +0000 (08:47 +0000)
committerTobias Hößl <tobias@hoessl.eu>
Tue, 17 Apr 2012 08:47:48 +0000 (08:47 +0000)
facebook/README
facebook/facebook.php [changed mode: 0755->0644]

index b68ba3da81e0094820adf08a227493bcf74ecc1d..5f74d2d4f731d5dec7eceb18800d2a91360f5898 100755 (executable)
@@ -1,43 +1,7 @@
 Installing the Friendica/Facebook connector
 
-1. Visit https://developers.facebook.com/apps to register an app.
-    a) Click "Create a new app"
-    b) We'd be very happy if you include "Friendica" in the application name
-       to increase name recognition.  
-    c) Edit your app settings on the setup page.  The Friendica icons are present
-       in the images directory and may be uploaded as a Facebook app icon.  Use 
-       images/friendica-16.jpg for the Icon and images/Friendica-128.jpg for the logo.
-    d) In the App Display name enter the name of your app (this should default to the
-       name you chose in part a).
-    e) Enter YourDomain.com in the App Domain field and hit return.
-    f) In "Select how your app connects with Facebook select "Website" and enter the 
-       full URL to your Friendica install including HTTPS and a trailing slash.
-
-2.    Enable the Facebook plugin by clicking on the icon next to it's name on the plugin
-      page of your admin panel.
-   b) return to the Facebook plugin page in your admin panel, and fill in the App-ID
-      and Application Secret settings you got from Facebook.
-   c) Click save.
-   d) Finally, return to the Facebook settings page, and activate real-time updates.
-
-       i. If you for any reason prefer to use a configuration file instead of the admin panels, 
-           Activate the plugin by including it in .htconfig.php, e.g.
-           
-               $a->config['system']['addon'] = 'plugin1,plugin2,facebook';
-       
-           and set the following values:
-               $a->config['facebook']['appid'] = 'xxxxxxxxxxx';
-               $a->config['facebook']['appsecret'] = 'xxxxxxxxxxxxxxx';
-
-           Replace with the settings Facebook gives you.
-       
-
-3.    To use the Facebook plugin, visit the "connector settings" area of your settings
-      page.  Click "Install Facebook Connector".  
-4.    This will ask you to login to Facebook and allow the plugin to do it's stuff.  
-      Allow it to do so.
-5.    You're done. To turn it off visit the Plugin Settings page again and
-      'Remove Facebook posting'.
+Detailed instructions how to use this plugin can be found at
+https://github.com/friendica/friendica/wiki/How-to:-Friendica%E2%80%99s-Facebook-connector
 
 Vidoes and embeds will not be posted if there is no other content. Links 
 and images will be converted to a format suitable for the Facebook API and 
old mode 100755 (executable)
new mode 100644 (file)
index c00ab6a..d681c4d
@@ -1,7 +1,7 @@
 <?php
 /**
  * Name: Facebook Connector
- * Version: 1.1
+ * Version: 1.2
  * Author: Mike Macgirvin <http://macgirvin.com/profile/mike>
  *         Tobias Hößl <https://github.com/CatoTH/>
  */
@@ -9,33 +9,8 @@
 /**
  * Installing the Friendica/Facebook connector
  *
- * 1. register an API key for your site from developer.facebook.com
- *   a. We'd be very happy if you include "Friendica" in the application name
- *      to increase name recognition. The Friendica icons are also present
- *      in the images directory and may be uploaded as a Facebook app icon.
- *      Use images/friendica-16.jpg for the Icon and images/friendica-128.jpg for the Logo.
- *   b. The url should be your site URL with a trailing slash.
- *      Friendica is a software application and does not require a Privacy Policy 
- *      or Terms of Service, though your installation of it might. Facebook may require
- *      that you provide a Privacy Policy, which we find ironic.  
- *   c. Set the following values in your .htconfig.php file
- *         $a->config['facebook']['appid'] = 'xxxxxxxxxxx';
- *         $a->config['facebook']['appsecret'] = 'xxxxxxxxxxxxxxx';
- *      Replace with the settings Facebook gives you.
- *   d. Navigate to Set Web->Site URL & Domain -> Website Settings.  Set 
- *      Site URL to yoursubdomain.yourdomain.com. Set Site Domain to your 
- *      yourdomain.com.
- * 2. Visit the Facebook Settings section of the "Settings->Plugin Settings" page.
- *    and click 'Install Facebook Connector'.
- * 3. Visit the Facebook Settings section of the "Settings->Plugin Settings" page.
- *    and click 'Install Facebook Connector'.
- * 4. This will ask you to login to Facebook and grant permission to the 
- *    plugin to do its stuff. Allow it to do so. 
- * 5. Optional step: If you want to use Facebook Real Time Updates (so new messages
- *    and new contacts are added ~1min after they are postet / added on FB), go to
- *    Settings -> plugins -> facebook and press the "Activate Real-Time Updates"-button.
- * 6. You're done. To turn it off visit the Plugin Settings page again and
- *    'Remove Facebook posting'.
+ * Detailed instructions how to use this plugin can be found at
+ * https://github.com/friendica/friendica/wiki/How-to:-Friendica%E2%80%99s-Facebook-connector
  *
  * Vidoes and embeds will not be posted if there is no other content. Links 
  * and images will be converted to a format suitable for the Facebook API and 
@@ -96,6 +71,10 @@ function facebook_module() {}
 // If a->argv[1] is a nickname, this is a callback from Facebook oauth requests.
 // If $_REQUEST["realtime_cb"] is set, this is a callback from the Real-Time Updates API
 
+/**
+ * @param $a
+ * @return mixed
+ */
 function facebook_init(&$a) {
        
        if (x($_REQUEST, "realtime_cb") && x($_REQUEST, "realtime_cb")) {
@@ -233,6 +212,10 @@ function facebook_init(&$a) {
 }
 
 
+/**
+ * @param $uid
+ * @return mixed
+ */
 function fb_get_self($uid) {
        $access_token = get_pconfig($uid,'facebook','access_token');
        if(! $access_token)
@@ -244,133 +227,169 @@ function fb_get_self($uid) {
        }
 }
 
-function fb_get_friends_sync_new($uid, $access_token, $person) {
-       $link = 'http://facebook.com/profile.php?id=' . $person->id;
-       
-       $r = q("SELECT * FROM `contact` WHERE `uid` = %d AND `url` = '%s' LIMIT 1",
-               intval($uid),
-               dbesc($link)
-       );
-       
-       if (count($r) == 0) {
-               logger('fb_get_friends: new contact found: ' . $link, LOGGER_DEBUG);
-               
-               fb_get_friends_sync_full($uid, $access_token, $person);
-       }
-}
-
-function fb_get_friends_sync_full($uid, $access_token, $person) {
-       $s = fetch_url('https://graph.facebook.com/' . $person->id . '?access_token=' . $access_token);
-       if($s) {
-               $jp = json_decode($s);
-               logger('fb_get_friends: info: ' . print_r($jp,true), LOGGER_DATA);
-
-               // always use numeric link for consistency
-
-               $jp->link = 'http://facebook.com/profile.php?id=' . $person->id;
-
-               // If its a page then set the first name from the username
-               if (!$jp->first_name and $jp->username)
-                       $jp->first_name = $jp->username;
-
-               // check if we already have a contact
+/**
+ * @param $uid
+ * @param $access_token
+ * @param $persons
+ */
+function fb_get_friends_sync_new($uid, $access_token, $persons) {
+    $persons_todo = array();
+    foreach ($persons as $person) {
+        $link = 'http://facebook.com/profile.php?id=' . $person->id;
+
+        $r = q("SELECT * FROM `contact` WHERE `uid` = %d AND `url` = '%s' LIMIT 1",
+            intval($uid),
+            dbesc($link)
+        );
+
+        if (count($r) == 0) {
+            logger('fb_get_friends: new contact found: ' . $link, LOGGER_DEBUG);
+            $persons_todo[] = $person;
+        }
 
-               $r = q("SELECT * FROM `contact` WHERE `uid` = %d AND `url` = '%s' LIMIT 1",
-                       intval($uid),
-                       dbesc($jp->link)
-               );                      
+        if (count($persons_todo) > 0) fb_get_friends_sync_full($uid, $access_token, $persons_todo);
+    }
+}
 
-               if(count($r)) {
+/**
+ * @param $uid
+ * @param $contact
+ * @return mixed
+ */
+function fb_get_friends_sync_parsecontact($uid, $contact) {
+    $contact->link = 'http://facebook.com/profile.php?id=' . $contact->id;
+
+    // If its a page then set the first name from the username
+    if (!$contact->first_name and $contact->username)
+        $contact->first_name = $contact->username;
+
+    // check if we already have a contact
+
+    $r = q("SELECT * FROM `contact` WHERE `uid` = %d AND `url` = '%s' LIMIT 1",
+        intval($uid),
+        dbesc($contact->link)
+    );
+
+    if(count($r)) {
+
+        // check that we have all the photos, this has been known to fail on occasion
+
+        if((! $r[0]['photo']) || (! $r[0]['thumb']) || (! $r[0]['micro'])) {
+            require_once("Photo.php");
+
+            $photos = import_profile_photo('https://graph.facebook.com/' . $contact->id . '/picture', $uid, $r[0]['id']);
+
+            $r = q("UPDATE `contact` SET `photo` = '%s',
+                                        `thumb` = '%s',
+                                        `micro` = '%s',
+                                        `name-date` = '%s',
+                                        `uri-date` = '%s',
+                                        `avatar-date` = '%s'
+                                        WHERE `id` = %d LIMIT 1
+                                ",
+                dbesc($photos[0]),
+                dbesc($photos[1]),
+                dbesc($photos[2]),
+                dbesc(datetime_convert()),
+                dbesc(datetime_convert()),
+                dbesc(datetime_convert()),
+                intval($r[0]['id'])
+            );
+        }
+        return;
+    }
+    else {
+
+        // create contact record
+        $r = q("INSERT INTO `contact` ( `uid`, `created`, `url`, `nurl`, `addr`, `alias`, `notify`, `poll`,
+                                `name`, `nick`, `photo`, `network`, `rel`, `priority`,
+                                `writable`, `blocked`, `readonly`, `pending` )
+                                VALUES ( %d, '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', %d, %d, %d, 0, 0, 0 ) ",
+            intval($uid),
+            dbesc(datetime_convert()),
+            dbesc($contact->link),
+            dbesc(normalise_link($contact->link)),
+            dbesc(''),
+            dbesc(''),
+            dbesc($contact->id),
+            dbesc('facebook ' . $contact->id),
+            dbesc($contact->name),
+            dbesc(($contact->nickname) ? $contact->nickname : strtolower($contact->first_name)),
+            dbesc('https://graph.facebook.com/' . $contact->id . '/picture'),
+            dbesc(NETWORK_FACEBOOK),
+            intval(CONTACT_IS_FRIEND),
+            intval(1),
+            intval(1)
+        );
+    }
 
-                       // check that we have all the photos, this has been known to fail on occasion
-
-                       if((! $r[0]['photo']) || (! $r[0]['thumb']) || (! $r[0]['micro'])) {  
-                               require_once("Photo.php");
-
-                               $photos = import_profile_photo('https://graph.facebook.com/' . $jp->id . '/picture', $uid, $r[0]['id']);
-
-                               $r = q("UPDATE `contact` SET `photo` = '%s', 
-                                       `thumb` = '%s',
-                                       `micro` = '%s', 
-                                       `name-date` = '%s', 
-                                       `uri-date` = '%s', 
-                                       `avatar-date` = '%s'
-                                       WHERE `id` = %d LIMIT 1
-                               ",
-                                       dbesc($photos[0]),
-                                       dbesc($photos[1]),
-                                       dbesc($photos[2]),
-                                       dbesc(datetime_convert()),
-                                       dbesc(datetime_convert()),
-                                       dbesc(datetime_convert()),
-                                       intval($r[0]['id'])
-                               );                      
-                       }       
-                       return;
-               }
-               else {
+    $r = q("SELECT * FROM `contact` WHERE `url` = '%s' AND `uid` = %d LIMIT 1",
+        dbesc($contact->link),
+        intval($uid)
+    );
 
-                       // create contact record 
-                       $r = q("INSERT INTO `contact` ( `uid`, `created`, `url`, `nurl`, `addr`, `alias`, `notify`, `poll`, 
-                               `name`, `nick`, `photo`, `network`, `rel`, `priority`,
-                               `writable`, `blocked`, `readonly`, `pending` )
-                               VALUES ( %d, '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', %d, %d, %d, 0, 0, 0 ) ",
-                               intval($uid),
-                               dbesc(datetime_convert()),
-                               dbesc($jp->link),
-                               dbesc(normalise_link($jp->link)),
-                               dbesc(''),
-                               dbesc(''),
-                               dbesc($jp->id),
-                               dbesc('facebook ' . $jp->id),
-                               dbesc($jp->name),
-                               dbesc(($jp->nickname) ? $jp->nickname : strtolower($jp->first_name)),
-                               dbesc('https://graph.facebook.com/' . $jp->id . '/picture'),
-                               dbesc(NETWORK_FACEBOOK),
-                               intval(CONTACT_IS_FRIEND),
-                               intval(1),
-                               intval(1)
-                       );
-               }
+    if(! count($r)) {
+        return;
+    }
 
-               $r = q("SELECT * FROM `contact` WHERE `url` = '%s' AND `uid` = %d LIMIT 1",
-                       dbesc($jp->link),
-                       intval($uid)
-               );
+    $contact = $r[0];
+    $contact_id  = $r[0]['id'];
+
+    require_once("Photo.php");
+
+    $photos = import_profile_photo($r[0]['photo'],$uid,$contact_id);
+
+    $r = q("UPDATE `contact` SET `photo` = '%s',
+                        `thumb` = '%s',
+                        `micro` = '%s',
+                        `name-date` = '%s',
+                        `uri-date` = '%s',
+                        `avatar-date` = '%s'
+                        WHERE `id` = %d LIMIT 1
+                ",
+        dbesc($photos[0]),
+        dbesc($photos[1]),
+        dbesc($photos[2]),
+        dbesc(datetime_convert()),
+        dbesc(datetime_convert()),
+        dbesc(datetime_convert()),
+        intval($contact_id)
+    );
+}
 
-               if(! count($r)) {
-                       return;
-               }
+/**
+ * @param $uid
+ * @param $access_token
+ * @param $persons
+ * @return mixed
+ */
+function fb_get_friends_sync_full($uid, $access_token, $persons) {
+    if (count($persons) == 0) return;
+    $nums = Ceil(count($persons) / 50);
+    for ($i = 0; $i < $nums; $i++) {
+        $batch_request = array();
+        for ($j = $i * 50; $j < ($i+1) * 50 && $j < count($persons); $j++) $batch_request[] = array('method'=>'GET', 'relative_url'=>$persons[$j]->id);
+        $s = post_url('https://graph.facebook.com/', array('access_token' => $access_token, 'batch' => json_encode($batch_request)));
+        if($s) {
+            $results = json_decode($s);
+            logger('fb_get_friends: info: ' . print_r($results,true), LOGGER_DATA);
+            foreach ($results as $contact) {
+                if ($contact->code != 200) logger('fb_get_friends: not found: ' . print_r($contact,true), LOGGER_DEBUG);
+                else fb_get_friends_sync_parsecontact($uid, json_decode($contact->body));
+            }
+        }
+    }
+}
 
-               $contact = $r[0];
-               $contact_id  = $r[0]['id'];
-
-               require_once("Photo.php");
-
-               $photos = import_profile_photo($r[0]['photo'],$uid,$contact_id);
-
-               $r = q("UPDATE `contact` SET `photo` = '%s', 
-                       `thumb` = '%s',
-                       `micro` = '%s', 
-                       `name-date` = '%s', 
-                       `uri-date` = '%s', 
-                       `avatar-date` = '%s'
-                       WHERE `id` = %d LIMIT 1
-               ",
-                       dbesc($photos[0]),
-                       dbesc($photos[1]),
-                       dbesc($photos[2]),
-                       dbesc(datetime_convert()),
-                       dbesc(datetime_convert()),
-                       dbesc(datetime_convert()),
-                       intval($contact_id)
-               );                      
 
-       }
-}
 
 // if $fullsync is true, only new contacts are searched for
 
+/**
+ * @param $uid
+ * @param bool $fullsync
+ * @return mixed
+ */
 function fb_get_friends($uid, $fullsync = true) {
 
        $r = q("SELECT `uid` FROM `user` WHERE `uid` = %d AND `account_expired` = 0 LIMIT 1",
@@ -394,17 +413,24 @@ function fb_get_friends($uid, $fullsync = true) {
                logger('facebook: fb_get_friends: json: ' . print_r($j,true), LOGGER_DATA);
                if(! $j->data)
                        return;
-               foreach($j->data as $person)
-                       if ($fullsync)
-                               fb_get_friends_sync_full($uid, $access_token, $person);
-                       else
-                               fb_get_friends_sync_new($uid, $access_token, $person);
+
+           $persons_todo = array();
+        foreach($j->data as $person) $persons_todo[] = $person;
+
+        if ($fullsync)
+            fb_get_friends_sync_full($uid, $access_token, $persons_todo);
+        else
+            fb_get_friends_sync_new($uid, $access_token, $persons_todo);
        }
 }
 
 // This is the POST method to the facebook settings page
 // Content is posted to Facebook in the function facebook_post_hook() 
 
+/**
+ * @param $a
+ * @return mixed
+ */
 function facebook_post(&$a) {
 
        $uid = local_user();
@@ -455,6 +481,10 @@ function facebook_post(&$a) {
 
 // Facebook settings form
 
+/**
+ * @param $a
+ * @return string
+ */
 function facebook_content(&$a) {
 
        if(! local_user()) {
@@ -478,7 +508,7 @@ function facebook_content(&$a) {
        if (get_pconfig(local_user(),'facebook','post')) {
                $access_token = get_pconfig(local_user(),'facebook','access_token');
                if ($access_token) {
-                       $private_wall = intval(get_pconfig($uid,'facebook','private_wall'));
+                       $private_wall = intval(get_pconfig(local_user(),'facebook','private_wall'));
                        $s = fetch_url('https://graph.facebook.com/me/feed?access_token=' . $access_token);
                        if($s) {
                                $j = json_decode($s);
@@ -556,11 +586,12 @@ function facebook_content(&$a) {
 }
 
 
-
+/**
+ * @param $a
+ * @param $b
+ * @return mixed
+ */
 function facebook_cron($a,$b) {
-//del_config('facebook', 'realtime_active');
-//del_config('facebook', 'realtime_err_mailsent');
-//del_config('facebook', 'cb_verify_token');
 
        $last = get_config('facebook','last_poll');
        
@@ -640,7 +671,10 @@ function facebook_cron($a,$b) {
 }
 
 
-
+/**
+ * @param $a
+ * @param $b
+ */
 function facebook_plugin_settings(&$a,&$b) {
 
        $b .= '<div class="settings-block">';
@@ -651,6 +685,10 @@ function facebook_plugin_settings(&$a,&$b) {
 }
 
 
+/**
+ * @param $a
+ * @param $o
+ */
 function facebook_plugin_admin(&$a, &$o){
 
 
@@ -695,7 +733,11 @@ function facebook_plugin_admin(&$a, &$o){
        }
 }
 
-function facebook_plugin_admin_post(&$a){
+/**
+ * @param $a
+ * @param $o
+ */
+function facebook_plugin_admin_post(&$a, &$o){
        check_form_security_token_redirectOnErr('/admin/plugins/facebook', 'fbsave');
        
        if (x($_REQUEST,'fb_save_keys')) {
@@ -714,6 +756,11 @@ function facebook_plugin_admin_post(&$a){
        }
 }
 
+/**
+ * @param $a
+ * @param $b
+ * @return mixed
+ */
 function facebook_jot_nets(&$a,&$b) {
        if(! local_user())
                return;
@@ -728,6 +775,11 @@ function facebook_jot_nets(&$a,&$b) {
 }
 
 
+/**
+ * @param $a
+ * @param $b
+ * @return mixed
+ */
 function facebook_post_hook(&$a,&$b) {
 
 
@@ -1102,6 +1154,10 @@ function facebook_post_hook(&$a,&$b) {
        }
 }
 
+/**
+ * @param $app
+ * @param $data
+ */
 function facebook_enotify(&$app, &$data) {
        if (x($data, 'params') && $data['params']['type'] == NOTIFY_SYSTEM && x($data['params'], 'system_type') && $data['params']['system_type'] == 'facebook_connection_invalid') {
                $data['itemlink'] = '/facebook';
@@ -1111,6 +1167,11 @@ function facebook_enotify(&$app, &$data) {
        }
 }
 
+/**
+ * @param $a
+ * @param $b
+ * @return mixed
+ */
 function facebook_post_local(&$a,&$b) {
 
        // Figure out if Facebook posting is enabled for this post and file it in 'postopts'
@@ -1137,6 +1198,11 @@ function facebook_post_local(&$a,&$b) {
 }
 
 
+/**
+ * @param $a
+ * @param $b
+ * @return mixed
+ */
 function fb_queue_hook(&$a,&$b) {
 
        $qi = q("SELECT * FROM `queue` WHERE `network` = '%s'",
@@ -1195,8 +1261,14 @@ function fb_queue_hook(&$a,&$b) {
        }
 }
 
+/**
+ * @param $access_token
+ * @param $since
+ * @return stdClass
+ */
 function fb_get_timeline($access_token, &$since) {
 
+    $entries = new stdClass();
        $entries->data = array();
        $newest = 0;
 
@@ -1235,6 +1307,10 @@ function fb_get_timeline($access_token, &$since) {
        return($entries);
 }
 
+/**
+ * @param $uid
+ * @return mixed
+ */
 function fb_consume_all($uid) {
 
        require_once('include/items.php');
@@ -1259,7 +1335,7 @@ function fb_consume_all($uid) {
        // Get the last date
        $lastdate = get_pconfig($uid,'facebook','lastdate');
        // fetch all items since the last date
-       $j = fb_get_timeline($access_token, &$lastdate);
+       $j = fb_get_timeline($access_token, $lastdate);
        if (isset($j->data)) {
                logger('fb_consume_stream: feed: ' . print_r($j,true), LOGGER_DATA);
                fb_consume_stream($uid,$j,false);
@@ -1270,6 +1346,11 @@ function fb_consume_all($uid) {
                logger('fb_consume_stream: feed: got no data from Facebook: ' . print_r($j,true), LOGGER_NORMAL);
 }
 
+/**
+ * @param $uid
+ * @param $link
+ * @return string
+ */
 function fb_get_photo($uid,$link) {
        $access_token = get_pconfig($uid,'facebook','access_token');
        if(! $access_token || (! stristr($link,'facebook.com/photo.php')))
@@ -1278,6 +1359,8 @@ function fb_get_photo($uid,$link) {
        $ret = preg_match('/fbid=([0-9]*)/',$link,$match);
        if($ret)
                $photo_id = $match[1];
+       else
+           return "";
        $x = fetch_url('https://graph.facebook.com/' . $photo_id . '?access_token=' . $access_token);
        $j = json_decode($x);
        if($j->picture)
@@ -1286,6 +1369,12 @@ function fb_get_photo($uid,$link) {
        //      return "\n" . '[url=' . $link . ']' . t('link') . '[/url]';
 }
 
+/**
+ * @param $uid
+ * @param $j
+ * @param bool $wall
+ * @return mixed
+ */
 function fb_consume_stream($uid,$j,$wall = false) {
 
        $a = get_app();
@@ -1658,7 +1747,7 @@ function fb_consume_stream($uid,$j,$wall = false) {
                                                        'to_email'     => $user[0]['email'],
                                                        'uid'          => $user[0]['uid'],
                                                        'item'         => $cmntdata,
-                                                       'link'             => $a->get_baseurl() . '/display/' . $importer['nickname'] . '/' . $item,
+                                                       'link'             => $a->get_baseurl() . '/display/' . $user[0]['nickname'] . '/' . $item,
                                                        'source_name'  => $cmntdata['author-name'],
                                                        'source_link'  => $cmntdata['author-link'],
                                                        'source_photo' => $cmntdata['author-avatar'],
@@ -1677,6 +1766,9 @@ function fb_consume_stream($uid,$j,$wall = false) {
 }
 
 
+/**
+ * @return bool|mixed|string
+ */
 function fb_get_app_access_token() {
        
        $acc_token = get_config('facebook','app_access_token');
@@ -1712,6 +1804,9 @@ function fb_get_app_access_token() {
        }
 }
 
+/**
+ *
+ */
 function facebook_subscription_del_users() {
        $a = get_app();
        $access_token = fb_get_app_access_token();
@@ -1722,6 +1817,9 @@ function facebook_subscription_del_users() {
        if (!facebook_check_realtime_active()) del_config('facebook', 'realtime_active');
 }
 
+/**
+ * @param bool $second_try
+ */
 function facebook_subscription_add_users($second_try = false) {
        $a = get_app();
        $access_token = fb_get_app_access_token();
@@ -1758,6 +1856,9 @@ function facebook_subscription_add_users($second_try = false) {
        };
 }
 
+/**
+ * @return null
+ */
 function facebook_subscriptions_get() {
        
        $access_token = fb_get_app_access_token();
@@ -1774,6 +1875,9 @@ function facebook_subscriptions_get() {
 }
 
 
+/**
+ * @return bool
+ */
 function facebook_check_realtime_active() {
        $ret = facebook_subscriptions_get();
        if (is_null($ret)) return false;
@@ -1787,7 +1891,14 @@ function facebook_check_realtime_active() {
 // DELETE-request to $url
 
 if(! function_exists('facebook_delete_url')) {
-function facebook_delete_url($url,$headers = null, &$redirects = 0, $timeout = 0) {
+    /**
+     * @param $url
+     * @param null $headers
+     * @param int $redirects
+     * @param int $timeout
+     * @return bool|string
+     */
+    function facebook_delete_url($url,$headers = null, &$redirects = 0, $timeout = 0) {
        $a = get_app();
        $ch = curl_init($url);
        if(($redirects > 8) || (! $ch)) 
@@ -1858,7 +1969,7 @@ function facebook_delete_url($url,$headers = null, &$redirects = 0, $timeout = 0
         $url_parsed = @parse_url($url);
         if (isset($url_parsed)) {
             $redirects++;
-            return delete_url($url,$headers,$redirects,$timeout);
+            return facebook_delete_url($url,$headers,$redirects,$timeout);
         }
     }
        $a->set_curl_code($http_code);