Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Checking for errors with $request #1

Open
fmdataweb opened this issue Jan 24, 2021 · 1 comment
Open

Checking for errors with $request #1

fmdataweb opened this issue Jan 24, 2021 · 1 comment

Comments

@fmdataweb
Copy link

Is there a way to check for any errors with the actual Xero API request (e.g. the GET Organisation request on line 75 of the index.php file):

    $request = $provider->getAuthenticatedRequest(
        'GET',
        'https://api.xero.com/api.xro/2.0/Organisation',
        $accessToken,
        $options
    );

I would like to add in some error checking to see if this request was successful and returned a 200 response (and not a 400 etc) - is there an built in way to do this?

@ajpgtech
Copy link

This is not an issue but a support call. Please redirect

However, to guide you, use a try catch

    try {
         ... your code
    } catch (\League\OAuth2\Client\Provider\Exception\IdentityProviderException $e) {
        // Failed to get the access token or user details.
        exit($e->getMessage());
    }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants