Sales Tax Calculator

FREEMIUM
Verified
Par SalesTaxIQ | Mise à jour 5 days ago | eCommerce
Popularité

9.6 / 10

Latence

418ms

Niveau de service

100%

Health Check

N/A

Retour à toutes les discussions

GEtting {"message":"Invalid API key. Go to https:\/\/docs.rapidapi.com\/docs\/keys for more info."

Rapid account: Mathison
mathison
2 years ago

I am writing in PHP and using curl.

I am copying the API key from the rapidapi website.
I am setting the headers in curl:

curl=curlinit();curlsetopt(curl = curl_init(); curl_setopt(curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt(curl,CURLOPTSSLVERIFYPEER,false);curlsetopt(curl, CURLOPT_SSL_VERIFYPEER, false); curl_setopt(curl, CURLOPT_SSLVERSION, 6);
curl_setopt($curl, CURLOPT_URL, $Url);

curl_setopt($curl, CURLOPT_HEADER, headers);curlsetopt(headers); curl_setopt(curl, CURLOPT_POSTFIELDS, http_build_query(fields));curlsetopt(fields)); curl_setopt(curl, CURLOPT_POST, 1);

where $headers = 
Array

(
[content-type] => application/json
[X-RapidAPI-Host] => sales-tax-calculator.p.rapidapi.com
[X-RapidAPI-Key] => XXX-value-I-copied-XXX
)

the URL = https://sales-tax-calculator.p.rapidapi.com/rates;

I have also tried setting CURLOPT_HTTPHEADER instead of CURLOPT_HEADER.

any thoughts on what I am doing wrong?
Thanks,
Joel

Rapid account: Mathison
mathison Commented 2 years ago

Thanks for the speedy reply.
The sample worked, my curl structures needed some help. So all fixed. Thank you.
A couple of questions:
I did not see the PHP example on the website. Am I missing something?
How often is your tax database updated?
How can I figure out regional exceptions for certain tax free merchandise - (clothing is tax free in certain places etc). any thoughts on how to handle this if you don’t

Thanks again,
Joel

Rapid account: Tax Pro Digital
TaxProDigital Commented 2 years ago

Hello! Thanks for the inquiry! It’s a little tough to debug where this may be failing with the markup issues in the message. Have you tried the sample PHP code and edit as needed for your input?

<?php

$curl = curl_init();

curl_setopt_array($curl, [
	CURLOPT_URL => "https://sales-tax-calculator.p.rapidapi.com/rates",
	CURLOPT_RETURNTRANSFER => true,
	CURLOPT_FOLLOWLOCATION => true,
	CURLOPT_ENCODING => "",
	CURLOPT_MAXREDIRS => 10,
	CURLOPT_TIMEOUT => 30,
	CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
	CURLOPT_CUSTOMREQUEST => "POST",
	CURLOPT_POSTFIELDS => "{\n    \"city\": \"Menlo Park\",\n    \"state\": \"CA\",\n    \"street\": \"1 Hacker Way\",\n    \"zip\": \"94025\"\n}",
	CURLOPT_HTTPHEADER => [
		"X-RapidAPI-Host: sales-tax-calculator.p.rapidapi.com",
		"X-RapidAPI-Key: XXX-value-I-copied-XXX",
		"content-type: application/json"
	],
]);

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
	echo "cURL Error #:" . $err;
} else {
	echo $response;
}
Rapid account: Mathison
mathison Commented 2 years ago

I see the message board munged some of the curl_setopt underbars into various letters. in my source it looks right and works fine in other curl conversations.
Joel

Participez à la discussion - ajoutez un commentaire ci-dessous:

Connectez-vous / Inscrivez-vous pour publier de nouveaux commentaires