Closed carcleo closed 1 year ago
I have the code
private function getLocation() : array{ $url = "https://api.ipgeolocation.io/ipgeo?apiKey=".env("IPGEOLOCATION_KEY"); $cURL = curl_init(); curl_setopt($cURL, CURLOPT_URL, $url); curl_setopt($cURL, CURLOPT_HTTPGET, true); curl_setopt($cURL, CURLOPT_RETURNTRANSFER, true); curl_setopt($cURL, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($cURL, CURLOPT_HTTPHEADER, array( 'Content-Type: application/json', 'Accept: application/json' )); $result = curl_exec($cURL); curl_close($cURL); return json_decode($result,1); }
case i put directly on the navigator in get mode
https://api.ipgeolocation.io/ipgeo?apiKey=".env("IPGEOLOCATION_KEY")
it returns correctly the IP adress, but...
by CURL it returns always a São Paulo/Brasil IP.
Why?
How i fix it?
in time:
with $.json({}) also it return corectly.
But i woud like of use Curl
Entendi que é preciso começar a requisição do navegador do cliente e não do server
I have the code
case i put directly on the navigator in get mode
https://api.ipgeolocation.io/ipgeo?apiKey=".env("IPGEOLOCATION_KEY")
it returns correctly the IP adress, but...
by CURL it returns always a São Paulo/Brasil IP.
Why?
How i fix it?
in time:
with $.json({}) also it return corectly.
But i woud like of use Curl