This repository has been archived by the owner on Oct 12, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
directory.php
73 lines (61 loc) · 1.87 KB
/
directory.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
<?php
require_once "header.php";
require_once "config.php";
require_once 'Zend/Loader.php';
Zend_Loader::loadClass('Zend_Gdata');
Zend_Loader::loadClass('Zend_Gdata_ClientLogin');
Zend_Loader::loadClass('Zend_Http_Client');
Zend_Loader::loadClass('Zend_Gdata_Query');
Zend_Loader::loadClass('Zend_Gdata_Feed');
try {
$client = Zend_Gdata_ClientLogin::getHttpClient($user, $pass, 'cp');
$gdata = new Zend_Gdata($client);
$gdata->setMajorProtocolVersion(3);
$query = new Zend_Gdata_Query('http://www.google.com/m8/feeds/contacts/default/full');
$query->setMaxResults("2147483647");
$query->setParam('orderby', 'lastmodified');
$query->setParam('sortorder', 'descending');
$feed = $gdata->getFeed($query);
?>
<CiscoIPPhoneDirectory>
<Title><?php echo $feed->title; ?></Title>
<Prompt>Options:</Prompt>
<?php
$results = array();
foreach($feed as $entry){
$obj = new stdClass;
$xml = simplexml_load_string($entry->getXML());
$obj->name = (string) $entry->title;
foreach ($xml->phoneNumber as $p) {
$obj->phoneNumber[] = (string) $p;
}
$results[] = $obj;
}
} catch (Exception $e) {
die('ERROR:' . $e->getMessage());
}
sort($results);
foreach ($results as $r) {
if($r->phoneNumber != null) {
foreach($r->phoneNumber as $phoneNumber) {
?>
<DirectoryEntry>
<Name><?php echo (!empty($r->name)) ? $r->name : 'Name not available'; ?></Name>
<Telephone><?php echo "$phoneNumber"; ?></Telephone>
</DirectoryEntry>
<?php
}
}
}
?>
<SoftKeyItem>
<Name>Dial</Name>
<URL>SoftKey:Dial</URL>
<Position>1</Position>
</SoftKeyItem>
<SoftKeyItem>
<Name>Exit</Name>
<URL>SoftKey:Exit</URL>
<Position>3</Position>
</SoftKeyItem>
</CiscoIPPhoneDirectory>