Skip to content

Commit a09ff46

Browse files
authored
Merge pull request #3 from dachcom-digital/array_fix
fix assoc array check
2 parents 2de5ae9 + 5c4216c commit a09ff46

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/Client/LinkedInSDK.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -116,8 +116,8 @@ public function getAccessToken(?string $authorization_code = null): string|bool
116116
$tmp_params = http_build_query($params);
117117

118118
$data = $this->_makeRequest(self::OAUTH_BASE . '/accessToken?' . $tmp_params, [], self::HTTP_METHOD_POST, ['x-li-format: json', 'Content-length: 0']);
119-
if (isset($data->error) && !empty($data->error) && !empty($data->error_description)) {
120-
throw new \RuntimeException('Access Token Request Error: ' . $data->error . ' -- ' . $data->error_description);
119+
if (isset($data['error'], $data['error_description']) && !empty($data['error']) && !empty($data['error_description'])) {
120+
throw new \RuntimeException('Access Token Request Error: ' . $data['error'] . ' -- ' . $data['error_description']);
121121
}
122122

123123
$this->accessToken = $data['access_token'];
@@ -292,7 +292,7 @@ protected function _makeRequest(
292292

293293
$response = json_decode($response, true, 512, JSON_THROW_ON_ERROR);
294294

295-
if (isset($response->status) && is_numeric($response->status) && ($response->status < 200 || $response->status > 300)) {
295+
if (isset($response['status']) && is_numeric($response['status']) && ($response['status'] < 200 || $response['status'] > 300)) {
296296
throw new \RuntimeException(json_encode($response, JSON_THROW_ON_ERROR));
297297
}
298298

0 commit comments

Comments
 (0)