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

XML response using XERO API / OAuth2.0 #120

Closed
Sandeep-MWP opened this issue May 11, 2020 · 1 comment
Closed

XML response using XERO API / OAuth2.0 #120

Sandeep-MWP opened this issue May 11, 2020 · 1 comment

Comments

@Sandeep-MWP
Copy link

SDK you're using (please complete the following information):

  • xeroapi/xero-php-oauth2 sdk version 1.6.2
  • Php version 5.6

Is your feature request related to a problem? Please describe.

  • When we send request into XERO API server using the XERO OAuth2.0 SDK to access Reports like -> Trial Balance, Profit and Loss and Balance Sheet. Our application needed the response for the Report request in XML format.
  • Does XeroAPI/xero-php-oauth2 support XML response? If “YES”, could you please suggest how would we include the “Accept” header parameter to “XML” during request using OAuth2.0 SDK.

Describe the solution you'd like

  • We needed XERO API to return XML response when "accept header" is set to XML using OAuth2.0 SDK.

Describe alternatives you've considered

  • We tried using PHP cURL instead to get XML response but could not get the token response in the first place. This issue is similar to the issue raised here

Could you please suggest a solution.
Thank you.

@SidneyAllen
Copy link
Contributor

Hi @Sandeep-MWP

xero-php-oauth2 only support JSON requests/responses. But you can use the league oauth2 client we bundle with our sdk to construct your own API call and parse the xml response.

The code would look something like this ....

`
$provider = new \League\OAuth2\Client\Provider\GenericProvider([
'clientId' => $clientId,
'clientSecret' => $clientSecret,
'redirectUri' => 'http://localhost:8888/oauth2',
'urlAuthorize' => 'https://login.xero.com/identity/connect/authorize',
'urlAccessToken' => 'https://identity.xero.com/connect/token',
'urlResourceOwnerDetails' => 'https://api.xero.com/api.xro/2.0/Invoices'
]);

$options['headers']['Accept'] = 'application/xml';
$connectionsResponse = $provider->getAuthenticatedRequest(
'GET',
'https://api.xero.com/api.xro/2.0/Reports/TrialBalance',
$accessToken,
$options
);
`

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