local works but in production it returns 403. Same PHP and Laravel version. Is there anything i can do?
$url = 'https://admin.appmax.com.br/api/v3/order/'.$order_id.'?access-token='.$token;
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => $url,
CURLOPT_HTTPHEADER => ['Content-Type: application/json'],
CURLOPT_CUSTOMREQUEST => 'GET',
CURLOPT_POST => true,
CURLOPT_RETURNTRANSFER => true
]);
$response = curl_exec($curl);
curl_close($curl);`
I did all the tests, it doesn’t work only in production.
2
Answers
You can try HTTP package.
You’re setting CURLOPT_POST to true, which indicates that you want to send a POST request, but you’re also setting CURLOPT_CUSTOMREQUEST to ‘GET’, which indicates that you want to send a GET request. You should remove the CURLOPT_POST option since you’re sending a GET request.
Neither you’re passing the access token as a header. You’re passing it as a query parameter in the URL.
Also, check the response for errors before processing it using curl_error.
The following should work.