xero-php
xero-php copied to clipboard
Setting a customer user-agent
Previously we were able to do the following
'curl' => [
CURLOPT_USERAGENT => $xeroUserAgent,
],
We used this so we can detect which isntance calls were coming from. Is this possible to do with with the updated library?
It's no longer required, but it IS possible. You have to set it on the transport object I think?
But also in the API history, when you click on an entry, it tells you the organisation it came from.
Yeah, I did see the possibility of setting the transport object, just checking that was the way to do it. Cheers. I'll finish off the development and get it connected and see where I go from there.
Hmm. Reopening this as I think it would be beneficial to have an option we can send through to set the user agent. We have multiple servers with different customers pointing the same App, so if there were errors coming through, having that quick user agent to tell us where the errors are occurring can sometimes be quite helpful. The attached screenshot is a bit much I think?
You can already do this.
// Reset the Transport to have the correct User-Agent for certification purposes $xero->setTransport($transport = new Client([ 'headers' => [ 'User-Agent' => 'blah blah blah here', // OAuth 2 Client ID 'Authorization' => sprintf('Bearer %s', $access_token), 'Xero-tenant-id' => $tenantID, ] ]));
Yeah, I realise that, but that's not exactly the best method here. As soon as any of that changes inside the library, it'll require constant updates
How about we make an update! As long as it ultimately confirms to https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/User-Agent, I think it's a great idea.
P.S. when I first made this library, I was automatically getting the package version and putting it in there, but decided to roll it back because it seemed like an unnecessary overhead. Maybe it's time to make it part of the release pipeline.
Awesome! Would you rather I try do a PR for this one @calcinai ?