를이 내 테스트 코드 사용 ========GDK 인증 PHP
<?php
include_once "templates/base.php";
session_start();
require_once realpath(dirname(__FILE__) . '/../autoload.php');
function get_service_client(){
$service_client_id="540223414844-tj91ijj3u99c44bhmftb8m20tgon57hc.apps.googleusercontent.com";
$service_email="[email protected]account.com";
$app_name="Eyenotes";
$key_file_location='C:/Users/Yuan/Desktop/eyenotes-81e92b7df1f1.p12';
$browser_api_key="AIzaSyAplINlgfGWGJ8pD1Bxlr8wg7i8ZNVOS1A";
$client = new Google_Client();
$client->setApplicationName("Eyenotes"); // Set your application name
$client->setClientId("540223414844-tj91ijj3u99c44bhmftb8m20tgon57hc.apps.googleusercontent.com");
$client->setDeveloperKey("AIzaSyAplINlgfGWGJ8pD1Bxlr8wg7i8ZNVOS1A");
$key = file_get_contents("C:/Users/Yuan/Desktop/eyenotes-81e92b7df1f1.p12");
$cred = new Google_Auth_AssertionCredentials(
$service_email,array('https://www.googleapis.com/auth/glass.thirdpartyauth'),$key
);
$client->setAssertionCredentials($cred);
return $client;
}
function insert_account($service,$userToken, $email)
{
$accountType='com.eyenotes';
$userDataArray= array();
$userData1= new Google_Service_Mirror_UserData();
$userData1->setKey('email');
$userData1->setValue("[email protected]");
$userDataArray[]=$userData1;
$authTokenArray= array();
$authToken1= new Google_Service_Mirror_AuthToken();
$authToken1->setAuthToken('randomtoken');
$authToken1->setType('randomType');
$authTokenArray[]=$authToken1;
$postBody = new Google_Service_Mirror_Account();
$postBody->setUserData($userDataArray);
$postBody->setAuthTokens($authTokenArray);
try {
$account = $service->accounts->insert($userToken, $accountType, $email, $postBody);
echo $account;
} catch (Exception $e) {
}
}
$service_client= get_service_client();
$mirrorService = new Google_Service_Mirror($service_client);
insert_account($mirrorService, "6164da1732ea09b4", "[email protected]");
?>
===================================
============================ : =======
이 내가 가진 예외입니다 ==============
Fatal error: Uncaught exception 'Google_Service_Exception' with message 'Error calling POST https://www.googleapis.com/mirror/v1/accounts/6164da1732ea09b4/com.eyenotes/ccfsz.public%40gmail.com?key=AIzaSyDxnl16J8Eiwv00k_1yzw_VoRr9wD32qao: (400) Invalid Value' in D:\MySoftware\wamp\www\insert\src\Google\Http\REST.php on line 111
Google_Service_Exception: Error calling POST https://www.googleapis.com/mirror/v1/accounts/6164da1732ea09b4/com.eyenotes/ccfsz.public%40gmail.com?key=AIzaSyDxnl16J8Eiwv00k_1yzw_VoRr9wD32qao: (400) Invalid Value in D:\MySoftware\wamp\www\insert\src\Google\Http\REST.php on line 111
======================= 매개 변수 설명 :
계정 유형이 Google에 제공됩니다.
사용자 토큰은 내가 Google에 제공하는 인증 URL에서 가져 왔습니다.
개발자 콘솔에서 새 키를 만들 때 브라우저 api 키가 생성됩니다.
내 코드에서 어떤 점이 문제인지 말해 주시겠습니까?
감사합니다.
예외가 발생하여 예외가 다시 발생하지는 않지만 mAccountManager.getAccountByType ("com.eyenotes")을 사용하여 계정 정보를 검색 할 수 없습니다. 그리고 Google 개발자 콘솔에서 성공적으로 요청한 것을 보여줍니다. 또 하나, Glassware에서 "ON"으로 전환 한 후 응용 프로그램을 가져올 수 없습니다. 이제는 글래스를 공장 초기화하려고합니다.하지만 2 시간이 지나면 다시 설정 한 것을 나타내는 정보를 얻지 못했습니다. (이제는 내 응용 프로그램이 공개적으로 표시되지 않습니다.)
정말 고맙습니다. 답변을 주셔서 감사합니다. 대단히 감사합니다. 다시 확인하고 다시 시도해 보겠습니다. – alens
안녕하세요. 나는 예외를 잡았고 다시 예외를 발생시키지 않았지만 mAccountManager.getAccountByType ("com.eyenotes");을 사용하여 계정 정보를 검색 할 수 없었다. Google 개발자 콘솔에서 성공적으로 요청한 것을 보여줍니다. 또 하나, Glassware.now에서 "ON"으로 토글 한 후 내 응용 프로그램을 가져올 수 없습니다. 내 유리를 공장 초기화하려고합니다.하지만 두 시간이 지나면 다시 설정 성공을 나타내는 정보를 얻지 못했습니다. (이제 내 응용 프로그램이 공개적으로 표시되지 않습니다). – alens