I need to insert user's email in postBody of mirror API insert method. I am using this code:
$authtoken=null;
$postBody = new Google_Service_Mirror_Account();
$postBody->setAuthTokens($authtoken);
$userdata=array("email"=>$email);
$postBody->setUserData($userdata);
$account = $service->accounts->insert($userToken, package-name-here, $accountName, $postBody);
The above method returns null in response! I am not sure what to add as authtoken.
After this, I need to retrieve user's email account through Android's account manager:
AccountManager manager = AccountManager.get(c);
Account[] list = manager.getAccountsByType(package-name-here);
for (Account acct : list) {
accountEmailId= manager.getUserData(acct, "email");
break;
}
This doesn't seem to work. I do not get accounts of this type in Glass device. Any help will be great.
EDIT: Added the authTokenArray and userDataArray to postBody as suggested below:
$userDataArray= array();
$userData1= new Google_Service_Mirror_UserData();
$userData1->setKey('email');
$userData1->setValue($email);
$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);
Account insert method still returns null. Unable to solve the issue till now.
[SOLVED] Mirror API still returns NULL response, but account is actually being inserted in Mirror API. Updated code can be viewed here: http://goo.gl/DVggO6