]> git.mxchange.org Git - friendica-addons.git/blobdiff - facebook/facebook.php
Merge branch 'master' of github.com:annando/friendica-addons
[friendica-addons.git] / facebook / facebook.php
index c09ac2fbe8c73ef8af6ab41a5ea43affbcb335bc..1e961fda309140484ce3e4070defa16d02966d84 100755 (executable)
@@ -1208,9 +1208,9 @@ function fb_get_timeline($access_token, &$since) {
                else
                        break;
 
-               $url = $s->paging->next;
+               $url = $j->paging->next;
 
-       } while (($oldestdate > $since) and ($since != 0));
+       } while (($oldestdate > $since) and ($since != 0) and ($url != ''));
 
        if ($newest > $since)
                $since = $newest;
@@ -1241,13 +1241,11 @@ function fb_consume_all($uid) {
        }
        // Get the last date
        $lastdate = get_pconfig($uid,'facebook','lastdate');
-       // echo "Alt: ".$lastdate."\n";
        // fetch all items since the last date
        $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);
-               // echo "Neu: ".$lastdate."\n";
 
                // Write back the last date
                set_pconfig($uid,'facebook','lastdate', $lastdate);
@@ -1340,16 +1338,9 @@ function fb_consume_stream($uid,$j,$wall = false) {
                        }
 
                        // don't store post if we don't have a contact
-
                        if(! x($datarray,'contact-id')) {
-                               //if (get_config('facebook', 'pages')) {
-                               //      // If no user is found then post it under the own id.
-                               //      // Definitely a quickhack
-                               //      $datarray['contact-id'] = $self[0]['id'];
-                               //} else {
-                                       logger('facebook: no contact '.$from->name.' '.$from->id.'. post ignored');
-                                       continue;
-                               //}
+                               logger('facebook: no contact '.$from->name.' '.$from->id.'. post ignored');
+                               continue;
                        }
 
                        $datarray['verb'] = ACTIVITY_POST;
@@ -1432,6 +1423,19 @@ function fb_consume_stream($uid,$j,$wall = false) {
                                }
                        }
 
+                       if (($datarray['app'] == "Events") and $entry->actions)
+                               foreach ($entry->actions as $action)
+                                       if ($action->name == "View")
+                                               $datarray['body'] .= " [url=".$action->link."]".$entry->story."[/url]";
+
+                       // Just as a test - to see if these are the missing entries
+                       //if(trim($datarray['body']) == '')
+                       //      $datarray['body'] = $entry->story;
+
+                       // Adding the "story" text to see if there are useful data in it (testing)
+                       //if (($datarray['app'] != "Events") and $entry->story)
+                       //      $datarray['body'] .= "\n".$entry->story;
+
                        if(trim($datarray['body']) == '') {
                                logger('facebook: empty body '.$entry->id.' '.print_r($entry, true));
                                continue;
@@ -1452,11 +1456,13 @@ function fb_consume_stream($uid,$j,$wall = false) {
                        //if(($datarray['body'] != '') and ($uid == 1))
                        //      $datarray['body'] .= "[noparse]".print_r($entry, true)."[/noparse]";
 
-                       if ($entry->place->name)
-                               $datarray['coord'] = $entry->place->name;
-                       else if ($entry->place->location->street or $entry->place->location->city or $entry->place->location->Denmark) {
+                       if ($entry->place->name or $entry->place->location->street or 
+                               $entry->place->location->city or $entry->place->location->Denmark) {
+                               $datarray['coord'] = '';
+                               if ($entry->place->name)
+                                       $datarray['coord'] .= $entry->place->name;
                                if ($entry->place->location->street)
-                                       $datarray['coord'] = $entry->place->location->street;
+                                       $datarray['coord'] .= $entry->place->location->street;
                                if ($entry->place->location->city)
                                        $datarray['coord'] .= " ".$entry->place->location->city;
                                if ($entry->place->location->country)