Merge pull request #348 from annando/1604-gplus-coord
Fromgplus: Add location and coordinates to postspull/349/head
commit
15eeb603ce
|
@ -129,7 +129,7 @@ function fromgplus_cron($a,$b) {
|
||||||
set_config('fromgplus','last_poll', time());
|
set_config('fromgplus','last_poll', time());
|
||||||
}
|
}
|
||||||
|
|
||||||
function fromgplus_post($a, $uid, $source, $body, $location) {
|
function fromgplus_post($a, $uid, $source, $body, $location, $coord) {
|
||||||
|
|
||||||
//$uid = 2;
|
//$uid = 2;
|
||||||
|
|
||||||
|
@ -164,6 +164,7 @@ function fromgplus_post($a, $uid, $source, $body, $location) {
|
||||||
$_REQUEST['title'] = $title;
|
$_REQUEST['title'] = $title;
|
||||||
$_REQUEST['body'] = $body;
|
$_REQUEST['body'] = $body;
|
||||||
$_REQUEST['location'] = $location;
|
$_REQUEST['location'] = $location;
|
||||||
|
$_REQUEST['coord'] = $coord;
|
||||||
|
|
||||||
if (($_REQUEST['title'] == "") AND ($_REQUEST['body'] == "")) {
|
if (($_REQUEST['title'] == "") AND ($_REQUEST['body'] == "")) {
|
||||||
logger('fromgplus: empty post for user '.$uid." ".print_r($_REQUEST, true));
|
logger('fromgplus: empty post for user '.$uid." ".print_r($_REQUEST, true));
|
||||||
|
@ -416,7 +417,6 @@ function fromgplus_fetch($a, $uid) {
|
||||||
|
|
||||||
$result = fetch_url("https://www.googleapis.com/plus/v1/people/".$account."/activities/public?alt=json&pp=1&key=".$key."&maxResults=".$maxfetch);
|
$result = fetch_url("https://www.googleapis.com/plus/v1/people/".$account."/activities/public?alt=json&pp=1&key=".$key."&maxResults=".$maxfetch);
|
||||||
//$result = file_get_contents("google.txt");
|
//$result = file_get_contents("google.txt");
|
||||||
//$result = file_get_contents("addon/fromgplus/album.txt");
|
|
||||||
//file_put_contents("google.txt", $result);
|
//file_put_contents("google.txt", $result);
|
||||||
|
|
||||||
$activities = json_decode($result);
|
$activities = json_decode($result);
|
||||||
|
@ -463,14 +463,23 @@ function fromgplus_fetch($a, $uid) {
|
||||||
if (is_array($item->object->attachments))
|
if (is_array($item->object->attachments))
|
||||||
$post .= fromgplus_handleattachments($a, $uid, $item, $item->object->content, false);
|
$post .= fromgplus_handleattachments($a, $uid, $item, $item->object->content, false);
|
||||||
|
|
||||||
// geocode, placeName
|
$coord = "";
|
||||||
if (isset($item->address))
|
$location = "";
|
||||||
$location = $item->address;
|
if (isset($item->location)) {
|
||||||
else
|
if (isset($item->location->address->formatted))
|
||||||
$location = "";
|
$location = $item->location->address->formatted;
|
||||||
|
|
||||||
//fromgplus_post($a, $uid, "Google+", $post, $location);
|
if (isset($item->location->displayName))
|
||||||
fromgplus_post($a, $uid, $item->provider->title, $post, $location);
|
$location = $item->location->displayName;
|
||||||
|
|
||||||
|
if (isset($item->location->position->latitude) AND
|
||||||
|
isset($item->location->position->longitude))
|
||||||
|
$coord = $item->location->position->latitude." ".$item->location->position->longitude;
|
||||||
|
|
||||||
|
} elseif (isset($item->address))
|
||||||
|
$location = $item->address;
|
||||||
|
|
||||||
|
fromgplus_post($a, $uid, $item->provider->title, $post, $location, $coord);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -505,13 +514,23 @@ function fromgplus_fetch($a, $uid) {
|
||||||
$post .= "\n".trim(fromgplus_handleattachments($a, $uid, $item, $item->object->content, true));
|
$post .= "\n".trim(fromgplus_handleattachments($a, $uid, $item, $item->object->content, true));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isset($item->address))
|
$coord = "";
|
||||||
$location = $item->address;
|
$location = "";
|
||||||
else
|
if (isset($item->location)) {
|
||||||
$location = "";
|
if (isset($item->location->address->formatted))
|
||||||
|
$location = $item->location->address->formatted;
|
||||||
|
|
||||||
//fromgplus_post($a, $uid, "Google+", $post, $location);
|
if (isset($item->location->displayName))
|
||||||
fromgplus_post($a, $uid, $item->provider->title, $post, $location);
|
$location = $item->location->displayName;
|
||||||
|
|
||||||
|
if (isset($item->location->position->latitude) AND
|
||||||
|
isset($item->location->position->longitude))
|
||||||
|
$coord = $item->location->position->latitude." ".$item->location->position->longitude;
|
||||||
|
|
||||||
|
} elseif (isset($item->address))
|
||||||
|
$location = $item->address;
|
||||||
|
|
||||||
|
fromgplus_post($a, $uid, $item->provider->title, $post, $location, $coord);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue