I am trying to make an api call with a curl wrapper. I made a new curl object and then tried to reference it and it says that i is undefined. This is the error below and it is refering to this line.
$curl->get("https://maps.googleapis.com/maps/api/geocode/json",
Notice: Undefined variable: curl in G:\wamp\www\voting\php\vote.php on line 18
<?php
require ('/vendor/autoload.php');
use \Curl\Curl;
$key = "";
$curl = new Curl();
function getLat(){
return explode(',',$_COOKIE['cord'])[0];
}
function getLong(){
return explode(',',$_COOKIE['cord'])[1];
}
function getLocationInfo(){
$lat = getLat();
$long = getLong();
$curl->get("https://maps.googleapis.com/maps/api/geocode/json",
array(
'latlng' => getLat().','.getlong(),
'key' => $key,
));
echo $curl->response->status;
}
function getDivision(){
}
?>
<?php
include("./php/vote.php");
echo getLocationInfo();
//echo $_COOKIE["cord"];
?>