I am not very good using PHP and cURL, normally I just make a call with either javascript or C# however I am working with wordpress so C# is not possibly, and I have an apikey with in the call url, so I was wondering if I could have some help with this. In javascript, the call would be.
var forecastOptions = {
"cache": false,
"dataType": "jsonp",
"url": callSite
};
var forecastRequest = $.ajax(forecastOptions);
I do it this way for my readability. I also don't want to turn on the "allow_url_fopen"
EDIT
So this is what I have now.
<?php
$api_key = 'xxxxxxxxxx';
$latitude = "40.5122";
$longitude = "-88.9886";
$API_ENDPOINT = 'https://api.forecast.io/forecast/';
$request_url = $API_ENDPOINT .
$api_key . '/' .
$latitude . ',' . $longitude;
$ch = curl_init();
$headers = array(
'Content-Type: application/json',
'Accept: application/json'
);
curl_setopt($ch, CURLOPT_URL, $request_url);
curl_setopt($ch, CURLOPT_HEADER, $headers);
$result = curl_exec($ch);
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
$content = json_decode($result, true);
if(empty($content)){
print_r("Empty");
}
?>
It is telling me that $content is empty. What am I missing if anything.