服务器上的镜像API身份验证

时间:2014-06-27 15:13:56

标签: oauth google-mirror-api aero-glass

我正试图从iOS应用程序中将卡插入我的杯子。为了做到这一点,我有一个iOS应用程序:

NSURL *url = [NSURL URLWithString:@"http://mydomain.com/server.php"];

然后,我的server.php使用Google的QuickStart项目将卡片发送到我的Glass。当我从计算机上启动此脚本时,我必须在登录后完美地发送我的卡。但是,当我从我的iOS应用程序中尝试它时,Google会向我发送登录页面。

<?php
require_once 'config.php';
require_once 'mirror-client.php';
require_once 'google-api-php-client/src/Google_Client.php';
require_once 'google-api-php-client/src/contrib/Google_MirrorService.php';
require_once 'util.php';

$client = get_google_api_client();

if (!isset($_SESSION['userid']) || get_credentials($_SESSION['userid']) == null) {
  header('Location: ' . $base_url . '/oauth2callback.php');
  exit;
} else {
  verify_credentials(get_credentials($_SESSION['userid']));
  $client->setAccessToken(get_credentials($_SESSION['userid']));
}

$mirror_service = new Google_MirrorService($client);

$new_timeline_item = new Google_TimelineItem();
$new_timeline_item->setText("YoNewFromApp!");

$notification = new Google_NotificationConfig();
$notification->setLevel("DEFAULT");
$new_timeline_item->setNotification($notification);

insert_timeline_item($mirror_service, $new_timeline_item, null, null);
?>

我不知道是否可以通过代码直接验证我的服务器,无需登录即可从任何地方调用我的API。

任何人都知道该怎么做?

我是Google Auth的新手,我不懂文档。 Thx提前。

0 个答案:

没有答案