public function request($path, $method = 'GET', $params = [], $headers = []) { $result = parent::request($path, $method, $params, $headers); $json_result = json_decode($result, true); if (isset($json_result['error'])) { if (isset($json_result['error']['error_subcode'])) { $error_subcode = $json_result['error']['error_subcode']; } else { $error_subcode = 'n/a'; } $error_type = $json_result['error']['type']; $error_code = $json_result['error']['code']; $error_message = $json_result['error']['message']; $msg = 'Error type: %s. Error code: %s. Error subcode: %s. Message: %s'; $msg = sprintf($msg, $error_type, $error_code, $error_subcode, $error_message); if ($error_type == 'OAuthException' && $error_code != 1 && strpos($error_message, 'Provided link was incorrect or disallowed') === false && strpos($error_message, 'Service temporarily unavailable') === false) { throw new ExpiredTokenException($msg); } else { if ($error_type == 'GraphMethodException' && $error_code == '100') { throw new AuthorizationException(); } else { throw new GenericPostingException($msg); } } } return $result; }
public function request($path, $method = 'GET', $params = [], $headers = []) { $headers['Content-Type'] = 'application/json'; $result = parent::request($path, $method, $params, $headers); $json_result = json_decode($result, true); // dd($json_result); if (isset($json_result['status']) && $json_result['status'] != 200) { $msg = 'Error accessing LinkedIn API. Status: %s. Error code: %s. Message: %s'; $msg = sprintf($msg, $json_result['status'], $json_result['errorCode'], $json_result['message']); if ($json_result['status'] == '401') { throw new ExpiredTokenException($msg); } else { throw new GenericPostingException($msg); } } return $result; }
/** * Twitter needs an extra step for authentication before providing an * authorization URL. * * @author Raúl Santos */ public function getAuthorizationUri(array $params = []) { $token = $this->service->requestRequestToken(); $extra = ['oauth_token' => $token->getRequestToken()]; return parent::getAuthorizationUri($extra); }