You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When using the GuzzleClient instead of the CurlClient, in some cases the GET parameters are not passed properly when making API calls according to Twilio documentation.
Steps to Reproduce
Inside the documentation it says we are to make the API call for looking up a phone number's carrier as follows:
Notice the "carrier" is null here instead of being an array, and the "url" is missing the ?Type=carrier portion. For some reason, the client is not passing the "type" GET parameter properly. To correct it, you can pass a string instead of an array for the "type" parameter, like so:
This issue has been added to our internal backlog to be prioritized. Pull requests and +1s on the issue summary will help it move up the backlog.
@charan678 +1. Twilio documentation has inconsistency.
cURL:
curl -X GET "https://lookups.twilio.com/v1/PhoneNumbers/(510)867-5310?CountryCode=US&Type=carrier" \
-u $TWILIO_ACCOUNT_SID:$TWILIO_AUTH_TOKEN
PHP:
<?php
// Update the path below to your autoload.php,
// see https://getcomposer.org/doc/01-basic-usage.md
require_once '/path/to/vendor/autoload.php';
use Twilio\Rest\Client;
// Find your Account SID and Auth Token at twilio.com/console
// and set the environment variables. See http://twil.io/secure
$sid = getenv("TWILIO_ACCOUNT_SID");
$token = getenv("TWILIO_AUTH_TOKEN");
$twilio = new Client($sid, $token);
$phone_number = $twilio->lookups->v1->phoneNumbers("(510)867-5310")
->fetch([
"countryCode" => "US",
"type" => ["carrier"]
]
);
print($phone_number->carrier);
As you can see, type is string in cURL example, but array in PHP example. What's expected here: string or array?
Issue Summary
When using the GuzzleClient instead of the CurlClient, in some cases the GET parameters are not passed properly when making API calls according to Twilio documentation.
Steps to Reproduce
Inside the documentation it says we are to make the API call for looking up a phone number's carrier as follows:
https://www.twilio.com/docs/lookup/quickstart?code-sample=code-lookup-with-national-formatted-number-1&code-language=PHP&code-sdk-version=6.x
The result returned is what you expect:
However, if you use the GuzzleClient and make the same request, the response is different:
Notice the "carrier" is
null
here instead of being an array, and the "url" is missing the?Type=carrier
portion. For some reason, the client is not passing the "type" GET parameter properly. To correct it, you can pass a string instead of an array for the "type" parameter, like so:This is either a mistake in the documentation, or a mistake in the implementation of the GuzzleClient.
Technical details:
The text was updated successfully, but these errors were encountered: