Skip to content
Snippets Groups Projects
Commit 63a50990 authored by Zoltán's avatar Zoltán
Browse files

refresh token bug fixed

destructor added
getdata() response error handling
parent 5ebd8c5a
No related branches found
No related tags found
No related merge requests found
......@@ -43,7 +43,8 @@ class AuthSCHClient {
}
public function __destruct() {
if(isset($this->tokens))
unset ($this->tokens);
}
private function curlExec($urlPart, $data) {
......@@ -109,7 +110,7 @@ class AuthSCHClient {
);
$ch = $this->curlExec("oauth2/token", $data);
$response = json_decode($ch);
$tokens = json_decode($ch);
if($tokens === null || !isset($tokens->access_token) || empty($tokens->access_token))
throw new Exception ("invalid token data");
......@@ -117,7 +118,19 @@ class AuthSCHClient {
}
public function getData() {
return json_decode(file_get_contents(self::$host . 'api/profile/?access_token=' . $this->tokens->access_token));
$response = @file_get_contents(self::$host . 'api/profile/?access_token=' . $this->tokens->access_token);
if(isset($response) && !empty($response)) {
$data = json_decode($response);
if($data !== null) {
return $data;
} else {
throw new Exception('invalid json');
}
} else {
if(isset($_SESSION['tokens']))
unset ($_SESSION['tokens']);
throw new Exception('invalid response');
}
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment