使用PHP进行Google Glass GDK身份验证
发布时间:2020-12-13 22:52:23 所属栏目:PHP教程 来源:网络整理
导读:我正在尝试按照此链接对GDK中的用户进行身份验证: https://developers.google.com/glass/develop/gdk/authentication 它在Java中给出了示例,但我的网页使用PHP.我知道我必须使用 https://github.com/google/google-api-php-client/blob/master/src/Google/S
我正在尝试按照此链接对GDK中的用户进行身份验证:
https://developers.google.com/glass/develop/gdk/authentication 它在Java中给出了示例,但我的网页使用PHP.我知道我必须使用 https://github.com/google/google-api-php-client/blob/master/src/Google/Service/Mirror.php 我坚持使用服务auth页面调用mirror.accounts.insert.不确定如何实现服务身份验证页面.任何例子都会有很大的帮助. [已解决]工作示例如下:http://goo.gl/DVggO6 解决方法
服务身份验证页面是用户在MyGlass中打开您的应用程序时打开的页面.您临时存储随该请求一起发送的userToken查询参数(不要永久存储它),然后根据您运行的后端对用户进行身份验证.然后,您可能会请求其Google帐户的适当范围(在这种情况下,您需要
https://www.googleapis.com/auth/glass.thirdpartyauth才能插入帐户).完成后,您可以在PHP中正常创建镜像服务,然后使用Accounts集合:
// $myClient would contain the typical Google_Client() setup // See PHP quickstart for example $myMirrorService = new Google_Service_Mirror($myClient); // Set your inputs to insert() as needed $accounts = $myMirrorService->accounts->insert($userToken,$accountType,$accountName,$postBody); 请注意,您只能在APK登陆MyGlass后进行测试并使用此API(在审核过程中会发生这种情况).我还建议使用Mirror API PHP Quickstart作为起点,以了解如果您尚未执行此操作,身份验证的工作原理. (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |