smartystreets / smartystreets-php-sdk

The official client libraries for accessing SmartyStreets APIs from the PHP Hypertext Processor.
https://smartystreets.com/docs/sdk/php
Apache License 2.0
28 stars 15 forks source link

[5.0.1] New `withXForwardedFor` autocomplete builder method results in incorrect HTTP header #56

Closed shengslogar closed 4 months ago

shengslogar commented 4 months ago

https://github.com/smartystreets/smartystreets-php-sdk/commit/0dc5c313641a42998103afb74d3b190d82773267#diff-2258d1b1c88120c093643b76c98deca30e816a85c7e3f9788be6b8013a6c85edR85-R88 introduced the withXForwardedFor method to allow passing an IP address to Smarty's autocomplete API for geographically-adjacent suggestions (related comment/issue).

In testing, this has no effect on API results.

https://github.com/smartystreets/smartystreets-php-sdk/blob/41f35cbb91d3a4a9d780cd76315aaeaba165c901/src/NativeSender.php#L85-L88

Changing the HTTP header results in an API response as expected. (Although the docs specify X-Forwarded-At, casing does not appear to be important.)

if ($this->ip != null) {
---   curl_setopt($ch, CURLOPT_HTTPHEADER, array("X_FORWARDED_FOR: $this->ip"));
+++   curl_setopt($ch, CURLOPT_HTTPHEADER, array("X-FORWARDED-FOR: $this->ip"));
      $smartyRequest->setHeader('X_FORWARDED_FOR', $this->ip);
}
RyanLCox1 commented 4 months ago

Thank you! This has been fixed with the release of 5.0.2

shengslogar commented 4 months ago

Thanks for the quick patch!