protected function gapi::authenticateUser in Google Analytics Statistics 7.x
Same name and namespace in other branches
- 7 includes/gapi.class.php \gapi::authenticateUser()
Authenticate Google Account with Google
Parameters
String $email:
String $password:
1 call to gapi::authenticateUser()
- gapi::__construct in inc/
gapi.class.php - Constructor function for all new gapi instances
File
- inc/
gapi.class.php, line 401
Class
- gapi
- GAPI - Google Analytics PHP Interface
Code
protected function authenticateUser($email, $password) {
$post_variables = array(
'accountType' => 'GOOGLE',
'Email' => $email,
'Passwd' => $password,
'source' => gapi::interface_name,
'service' => 'analytics',
);
$response = $this
->httpRequest(gapi::client_login_url, null, $post_variables);
//Convert newline delimited variables into url format then import to array
parse_str(str_replace(array(
"\n",
"\r\n",
), '&', $response['body']), $auth_token);
if (substr($response['code'], 0, 1) != '2' || !is_array($auth_token) || empty($auth_token['Auth'])) {
throw new Exception('GAPI: Failed to authenticate user. Error: "' . strip_tags($response['body']) . '"');
}
$this->auth_token = $auth_token['Auth'];
}