'Laravel Http Client Request How To Include An Array Of Strings?
I want to send a Http Client Request to Bluehost Domains API. I want to include an array of domain names and an array of tlds In my request, as follows:
public function multipleDomainsAvailable($domainsArray, $tldArray)
{
$urlSegments = "api/domains/available.json";
$response = Http::dd()->get("https://test.httpapi.com/" . $urlSegments, [
'auth-userid' => xxxxxxxx,
'api-key' => env('BLUEHOST_API_KEY_DEMO'),
'domain-name' => $domainsArray,
'tlds' => $tldArray,
]);
if(! $response->ok())
{
return $response->body();
}
return $response->json();
}
$domainsArray is an array of strings and so is $tldArray. When I dump the response, I get some weird encoding between the domain-name and the value?
auth-userid=xxxxxxxx&api-key=myKey&domain-name%5B0%5D=smurfs&domain-name%5B1%5D=weirdness&domain-name%5B2%5D=fellow&domain-name%5B3%5D=demonize&tlds%5B0%5D=com&tlds%5B1%5D=net&tlds%5B2%5D=org&tlds%5B3%5D=info"
I get an error message saying the required parameter domain-name is missing?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
