-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathleads.php
79 lines (59 loc) · 1.94 KB
/
leads.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
<!DOCTYPE html>
<html lang="de-DE">
<head>
<meta charset="UTF-8" />
</head><body>
<?php
require_once 'podioConfig.php';
/* podioConfig.php:
define("CLIENT_ID", "xxx");
define("CLIENT_SECRET", "xxx");
define("APP_ID", "xxx");
define("APP_TOKEN", "xxx");
*/
require_once 'podio/PodioAPI.php';
ini_set('display_errors', '1');
Podio::setup(CLIENT_ID, CLIENT_SECRET);
Podio::authenticate('app', array('app_id' => APP_ID, 'app_token' => APP_TOKEN));
$items = PodioItem::filter(APP_ID, array('limit' => 500));
?>
<table>
<?php
foreach ($items['items'] as $key => $lead) {
if($lead->field('zip-codepost-code') && $lead->field('street-address') && $lead->field('city')) {
$address = $lead->field('street-address')->humanized_value()
. ", "
. $lead->field('zip-codepost-code')->humanized_value()
. " "
. $lead->field('city')->humanized_value();
if($lead->field('country')) {
$address = $address . ", " . $lead->field('country')->humanized_value();
}
} else {
$address = false;
}
if( !$address) {
continue;
}
$url = "http://maps.google.com/maps/api/geocode/json?address=" . urlencode($address) . "&sensor=false";
$geocode=file_get_contents($url);
$output = json_decode($geocode);
if(count($output->results) > 0) {
PodioItem::update($lead->item_id, array('fields' => array(
"latlon" => $output->results[0]->geometry->location->lat . "," . $output->results[0]->geometry->location->lng
)), array('silent'=>1));
}
//$lead->fields['latlon'] = new PodioTextItemField('latlon');
//$lead->field('latlon') = new PodioTextItemField('latlon');
//$lead->field('latlon')->set_value($output->results[0]->geometry->location->lat . "," . $output->results[0]->geometry->location->lng)->save();
?>
<tr><td><?=$lead -> field('company-or-organisation') -> humanized_value() ?></td>
<td></td>
<td><?php echo $address; ?></td>
</tr>
<?php
}
?>
</table>
</body>
</html>