Mirror Service

The Mirror service allows you to use the Google Mirror API in Apps Script. This API gives users the ability to interact with Google Glass.

Reference

For detailed information on this service, see the reference documentation for the Google Mirror API. Like all advanced services in Apps Script, the Mirror service uses the same objects, methods, and parameters as the public API.

Sample code

The sample code below uses version 1 of the API.

Open code in new window

Insert timeline item

This sample inserts a new item into the timeline.

function insertTimelineItem() {
  var timelineItem = Mirror.newTimelineItem();
  timelineItem.text = 'Hello world!';

  var notificationConfig = Mirror.newNotificationConfig();
  notificationConfig.level = 'AUDIO_ONLY';

  var menuItem = Mirror.newMenuItem();
  menuItem.action = 'REPLY';

  timelineItem.notification = notificationConfig;
  timelineItem.menuItems = [menuItem];

  Mirror.Timeline.insert(timelineItem);
}

Insert contact

This sample inserts a new contact.

function insertContact() {
  var contact = {
    id: 'harold',
    displayName: 'Harold Penguin',
    imageUrls: ['https://developers.google.com/glass/images/harold.jpg']
  };

  Mirror.Contacts.insert(contact);
}

Get latest location

This sample prints the most recent known location of the user's Glass to the script editor's log.

/**
 * This sample prints the most recent known location of the user's Glass to the
 * script editor's log.
 */
function printLatestLocation() {
  var location = Mirror.Locations.get('latest');

  Logger.log('Location recorded on: ' + location.timestamp);
  Logger.log('  > Latitude: ' + location.latitude);
  Logger.log('  > Longitude: ' + location.longitude);
  Logger.log('  > Accuracy: ' + location.accuracy + ' meters');
}

发送以下问题的反馈:

此网页
Apps Script
Apps Script