Google Glass中的“分享”按钮在何处发送数据?

时间:2014-06-10 13:02:16

标签: php google-glass google-mirror-api

我刚刚开始探索Google Glass的功能。

我尝试做的是一个简单的玻璃器皿,当默认情况下共享'分享'功能被使用。

我看到了Quickstart project guide,我设法在python demo project上传了我的视频;我还设法在我的服务器中实现示例PHP项目代码。

然而,我仍然无法弄清楚我在哪里点击"分享"我的玻璃上的按钮:在哪里发送数据?到我的Glassware,通用镜像API,还是其他地方?我认为Share功能正在做类似media upload page中描述的内容,但它不清楚如何。

当我上传图片/视频时,演示项目的代码似乎更新了时间轴事件;但是,如果我没有错,这段代码只是使用&#34更新已存在的项目;我已收到您的数据!"标题。

(我将在此处报告Google notify.php示例中的相关代码:)

switch ($request['collection']) {
    case 'timeline':
    // Verify that it's a share
    foreach ($request['userActions'] as $i => $user_action) {
      if ($user_action['type'] == 'SHARE') {

        $timeline_item_id = $request['itemId'];

        $timeline_item = $mirror_service->timeline->get($timeline_item_id);

        // Patch the item. Notice that since we retrieved the entire item above
        // in order to access the caption, we could have just changed the text
        // in place and used the update method, but we wanted to illustrate the
        // patch method here.
        $patch = new Google_TimelineItem();
        $patch->setText("PHP Quick Start got your photo! " .
            $timeline_item->getText());
        $mirror_service->timeline->patch($timeline_item_id, $patch);
        break;
      }
    }

... 

实际收到视频的地点和时间?我需要知道这一点,以便在收到数据时执行其他操作。

1 个答案:

答案 0 :(得分:0)

通过Quickstart PHP项目的mirror-client.php中的download_attachment功能下载共享图片或视频。

这是功能:

 /**
 * Download an attachment's content.
 *
 * @param string item_id ID of the timeline item the attachment belongs to.
 * @param Google_Attachment $attachment Attachment's metadata.
 * @return string The attachment's content if successful, null otherwise.
 */
function download_attachment($item_id, $attachment) {
  $request = new Google_HttpRequest($attachment->getContentUrl(), 'GET', null, null);
  $httpRequest = Google_Client::$io->authenticatedRequest($request);
  if ($httpRequest->getResponseHttpCode() == 200) {
    return $httpRequest->getResponseBody();
  } else {
    // An error occurred.
    return null;
  }
}