|
37 | 37 |
|
38 | 38 | // But first, handle POST data from the form (if there is any)
|
39 | 39 | switch ($_POST['operation']) {
|
40 |
| - case "insertItem": |
| 40 | + case 'insertItem': |
41 | 41 | $new_timeline_item = new Google_TimelineItem();
|
42 | 42 | $new_timeline_item->setText($_POST['message']);
|
43 | 43 |
|
|
46 | 46 | $new_timeline_item->setNotification($notification);
|
47 | 47 |
|
48 | 48 | if (isset($_POST['imageUrl']) && isset($_POST['contentType'])) {
|
49 |
| - insertTimelineItem($mirror_service, $new_timeline_item, |
| 49 | + insert_timeline_item($mirror_service, $new_timeline_item, |
50 | 50 | $_POST['contentType'], file_get_contents($_POST['imageUrl']));
|
51 | 51 | } else {
|
52 |
| - insertTimelineItem($mirror_service, $new_timeline_item, null, null); |
| 52 | + insert_timeline_item($mirror_service, $new_timeline_item, null, null); |
53 | 53 | }
|
54 | 54 |
|
55 | 55 | $message = "Timeline Item inserted!";
|
56 | 56 | break;
|
57 |
| - case "insertItemWithAction": |
| 57 | + case 'insertItemWithAction': |
58 | 58 | $new_timeline_item = new Google_TimelineItem();
|
59 | 59 | $new_timeline_item->setText("What did you have for lunch?");
|
60 | 60 |
|
61 | 61 | $notification = new Google_NotificationConfig();
|
62 | 62 | $notification->setLevel("DEFAULT");
|
63 | 63 | $new_timeline_item->setNotification($notification);
|
64 | 64 |
|
65 |
| - $menuItems = array(); |
| 65 | + $menu_items = array(); |
66 | 66 |
|
67 | 67 | // A couple of built in menu items
|
68 |
| - $menuItem = new Google_MenuItem(); |
69 |
| - $menuItem->setAction("READ_ALOUD"); |
70 |
| - array_push($menuItems, $menuItem); |
| 68 | + $menu_item = new Google_MenuItem(); |
| 69 | + $menu_item->setAction("READ_ALOUD"); |
| 70 | + array_push($menu_items, $menu_item); |
71 | 71 | $new_timeline_item->setSpeakableText("What did you eat? Bacon?");
|
72 | 72 |
|
73 |
| - $menuItem = new Google_MenuItem(); |
74 |
| - $menuItem->setAction("SHARE"); |
75 |
| - array_push($menuItems, $menuItem); |
| 73 | + $menu_item = new Google_MenuItem(); |
| 74 | + $menu_item->setAction("SHARE"); |
| 75 | + array_push($menu_items, $menu_item); |
76 | 76 |
|
77 | 77 | // A custom menu item
|
78 |
| - $customMenuItem = new Google_MenuItem(); |
79 |
| - $customMenuValue = new Google_MenuValue(); |
80 |
| - $customMenuValue->setDisplayName("Drill Into"); |
81 |
| - $customMenuValue->setIconUrl($service_base_url . "/static/images/drill.png"); |
| 78 | + $custom_menu_item = new Google_MenuItem(); |
| 79 | + $custom_menu_value = new Google_MenuValue(); |
| 80 | + $custom_menu_value->setDisplayName("Drill Into"); |
| 81 | + $custom_menu_value->setIconUrl($service_base_url . "/static/images/drill.png"); |
82 | 82 |
|
83 |
| - $customMenuItem->setValues(array($customMenuValue)); |
84 |
| - $customMenuItem->setAction("CUSTOM"); |
| 83 | + $custom_menu_item->setValues(array($custom_menu_value)); |
| 84 | + $custom_menu_item->setAction("CUSTOM"); |
85 | 85 | // This is how you identify it on the notification ping
|
86 |
| - $customMenuItem->setId("safe-for-later"); |
87 |
| - array_push($menuItems, $customMenuItem); |
| 86 | + $custom_menu_item->setId("safe-for-later"); |
| 87 | + array_push($menu_items, $custom_menu_item); |
88 | 88 |
|
89 |
| - $new_timeline_item->setMenuItems($menuItems); |
| 89 | + $new_timeline_item->setMenuItems($menu_items); |
90 | 90 |
|
91 |
| - insertTimelineItem($mirror_service, $new_timeline_item, null, null); |
| 91 | + insert_timeline_item($mirror_service, $new_timeline_item, null, null); |
92 | 92 |
|
93 | 93 | $message = "Inserted a timeline item you can reply to";
|
94 | 94 | break;
|
95 |
| - case "insertTimelineAllUsers": |
| 95 | + case 'insertTimelineAllUsers': |
96 | 96 | $credentials = list_credentials();
|
97 | 97 | if (count($credentials) > 10) {
|
98 | 98 | $message = "Found " . count($credentials) . " users. Aborting to save your quota.";
|
|
106 | 106 |
|
107 | 107 | $user_specific_mirror_service = new Google_MirrorService($user_specific_client);
|
108 | 108 |
|
109 |
| - insertTimelineItem($user_specific_mirror_service, $new_timeline_item, null, null); |
| 109 | + insert_timeline_item($user_specific_mirror_service, $new_timeline_item, null, null); |
110 | 110 | }
|
111 | 111 | $message = "Sent a cat fact to " . count($credentials) . " users.";
|
112 | 112 | }
|
113 | 113 | break;
|
114 |
| - case "insertSubscription": |
115 |
| - $message = subscribeToNotifications($mirror_service, $_POST['subscriptionId'], |
| 114 | + case 'insertSubscription': |
| 115 | + $message = subscribe_to_notifications($mirror_service, $_POST['subscriptionId'], |
116 | 116 | $_SESSION['userid'], $base_url . "/notify.php");
|
117 | 117 | break;
|
118 |
| - case "deleteSubscription": |
| 118 | + case 'deleteSubscription': |
119 | 119 | $message = $mirror_service->subscriptions->delete($_POST['subscriptionId']);
|
120 | 120 | break;
|
121 |
| - case "insertContact": |
122 |
| - insertContact($mirror_service, $_POST['id'], $_POST['name'], |
| 121 | + case 'insertContact': |
| 122 | + insert_contact($mirror_service, $_POST['id'], $_POST['name'], |
123 | 123 | $base_url . "/static/images/chipotle-tube-640x360.jpg");
|
124 | 124 | $message = "Contact inserted. Enable it on MyGlass.";
|
125 | 125 | break;
|
126 |
| - case "deleteContact": |
127 |
| - deleteContact($mirror_service, $_POST['id']); |
| 126 | + case 'deleteContact': |
| 127 | + delete_contact($mirror_service, $_POST['id']); |
128 | 128 | $message = "Contact deleted.";
|
129 | 129 | break;
|
130 | 130 | }
|
|
138 | 138 | $contact = null;
|
139 | 139 | }
|
140 | 140 | $subscriptions = $mirror_service->subscriptions->listSubscriptions();
|
141 |
| -$timelineSubscriptionExists = false; |
142 |
| -$locationSubscriptionExists = false; |
143 |
| -foreach ($subscriptions['items'] as $subscription) { |
144 |
| - if ($subscription['id'] == 'timeline') { |
145 |
| - $timelineSubscriptionExists = true; |
146 |
| - } elseif ($subscription['id'] == 'location') { |
147 |
| - $locationSubscriptionExists = true; |
| 141 | +$timeline_subscription_exists = false; |
| 142 | +$location_subscription_exists = false; |
| 143 | +foreach ($subscriptions->getItems() as $subscription) { |
| 144 | + if ($subscription->getId() == 'timeline') { |
| 145 | + $timeline_subscription_exists = true; |
| 146 | + } elseif ($subscription->getId() == 'location') { |
| 147 | + $location_subscription_exists = true; |
148 | 148 | }
|
149 | 149 | }
|
150 | 150 |
|
|
184 | 184 | <div class="hero-unit">
|
185 | 185 | <h1>Your Recent Timeline</h1>
|
186 | 186 | <?php if ($message != "") { ?>
|
187 |
| - <span class="label label-warning">Message: <?= $message ?> </span> |
| 187 | + <span class="label label-warning">Message: <?php echo $message; ?> </span> |
188 | 188 | <?php } ?>
|
189 | 189 |
|
190 | 190 | <div style="margin-top: 5px;">
|
191 |
| - <?php foreach ($timeline['items'] as $timeline_item) { ?> |
| 191 | + <?php foreach ($timeline->getItems() as $timeline_item) { ?> |
192 | 192 | <ul class="span3 tile">
|
193 |
| - <li><strong>ID: </strong> <?= $timeline_item['id'] ?> |
| 193 | + <li><strong>ID: </strong> <?php echo $timeline_item->getId(); ?> |
194 | 194 | </li>
|
195 | 195 | <li>
|
196 |
| - <strong>Text: </strong> <?= $timeline_item['text'] ?> |
| 196 | + <strong>Text: </strong> <?php echo $timeline_item->getId(); ?> |
197 | 197 | </li>
|
198 | 198 | <li>
|
199 | 199 | <strong>Attachments: </strong>
|
200 | 200 | <?php
|
201 |
| - if (isset($timeline_item['attachments'])) { |
202 |
| - $attachments = $timeline_item['attachments']; |
| 201 | + if ($timeline_item->getAttachments() != null) { |
| 202 | + $attachments = $timeline_item->getAttachments(); |
203 | 203 | foreach ($attachments as $attachment) { ?>
|
204 |
| - <img src="<?= $base_url . |
205 |
| - '/attachment-proxy.php?timeline_item_id='. |
206 |
| - $timeline_item['id'].'&attachment_id='.$attachment['id'] ?>" /> |
| 204 | + <img src="<?php echo $base_url . |
| 205 | + '/attachment-proxy.php?timeline_item_id=' . |
| 206 | + $timeline_item->getId() . '&attachment_id=' . |
| 207 | + $attachment->getId() ?>" /> |
207 | 208 | <?php
|
208 | 209 | }
|
209 | 210 | }
|
|
236 | 237 | <input type="hidden" name="operation" value="insertItem">
|
237 | 238 | <input type="hidden" name="message"
|
238 | 239 | value="Chipotle says hi!">
|
239 |
| - <input type="hidden" name="imageUrl" value="<?= $base_url . |
| 240 | + <input type="hidden" name="imageUrl" value="<?php echo $base_url . |
240 | 241 | "/static/images/chipotle-tube-640x360.jpg" ?>">
|
241 | 242 | <input type="hidden" name="contentType" value="image/jpeg">
|
242 | 243 |
|
243 | 244 | <button class="btn" type="submit">A picture
|
244 |
| - <img class="button-icon" src="<?= $base_url . |
| 245 | + <img class="button-icon" src="<?php echo $base_url . |
245 | 246 | "/static/images/chipotle-tube-640x360.jpg" ?>">
|
246 | 247 | </button>
|
247 | 248 | </form>
|
|
265 | 266 | <?php if ($contact == null) { ?>
|
266 | 267 | <form class="span3"method="post">
|
267 | 268 | <input type="hidden" name="operation" value="insertContact">
|
268 |
| - <input type="hidden" name="iconUrl" value="<?= $base_url . |
| 269 | + <input type="hidden" name="iconUrl" value="<?php echo $base_url . |
269 | 270 | "/static/images/chipotle-tube-640x360.jpg" ?>">
|
270 | 271 | <input type="hidden" name="name" value="PHP Quick Start">
|
271 | 272 | <input type="hidden" name="id" value="php-quick-start">
|
|
277 | 278 | <input type="hidden" name="id" value="php-quick-start">
|
278 | 279 | <button class="btn" type="submit">Delete PHP Quick Start Contact</button>
|
279 | 280 | </form>
|
280 |
| - <? } ?> |
| 281 | + <?php } ?> |
281 | 282 | </div>
|
282 | 283 |
|
283 | 284 | <div class="span4">
|
|
290 | 291 | <p class="label label-info">Note: Subscriptions require SSL. <br>They will
|
291 | 292 | not work on localhost.</p>
|
292 | 293 |
|
293 |
| - <?php if ($timelineSubscriptionExists) { ?> |
| 294 | + <?php if ($timeline_subscription_exists) { ?> |
294 | 295 | <form method="post">
|
295 | 296 | <input type="hidden" name="subscriptionId" value="timeline">
|
296 | 297 | <input type="hidden" name="operation" value="deleteSubscription">
|
297 | 298 | <button class="btn" type="submit">Unsubscribe from
|
298 | 299 | timeline updates</button>
|
299 | 300 | </form>
|
300 |
| - <? } else { ?> |
| 301 | + <?php } else { ?> |
301 | 302 | <form method="post">
|
302 | 303 | <input type="hidden" name="operation" value="insertSubscription">
|
303 | 304 | <input type="hidden" name="subscriptionId" value="timeline">
|
304 | 305 | <button class="btn" type="submit">Subscribe to timeline updates</button>
|
305 | 306 | </form>
|
306 | 307 | <?php } ?>
|
307 | 308 |
|
308 |
| - <?php if ($locationSubscriptionExists) { ?> |
| 309 | + <?php if ($location_subscription_exists) { ?> |
309 | 310 | <form method="post">
|
310 | 311 | <input type="hidden" name="subscriptionId" value="location">
|
311 | 312 | <input type="hidden" name="operation" value="deleteSubscription">
|
|
0 commit comments