I need to insert the user's email address in the postBody method for the mirrored API. 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 that, I need to get the email user account through the Android 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 does not work. I do not receive bills of this type in a glass device. Any help would be great.
EDIT: Added authTokenArray and userDataArray for 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);
The account insertion method still returns null. Could not solve the problem so far.
[SOLVED] Mirror API still returns a NULL response, but the account is actually inserted into the Mirror API. The updated code can be found here: http://goo.gl/DVggO6
source share