I have made a simple api end point using Kimono for pulling Arkansas Waterfowl Reports and their respective post dates.
I am given the below api url from Kimono:
curl --include --request GET "http://www.kimonolabs.com/api/e45oypq8?apikey=XXXXX"
Because I am not familiar with how to pull data using cURL, I went to the web and read multiple articles, tutorials on pulling data from an api using cURL. I feel that there is about 1 million ways to do this. I have spent too much time banging head on desk. This is what I came up with:
<!DOCTYPE html>
<html>
<body>
<?php
$json_string = file_get_contents("http://www.kimonolabs.com/api/e45oypq8?apikey=XXX");
$parsed_json = json_decode($json_string);
$title = $parsed_json->{'results'}->{'collection1'}->{'title'};
$posted = $parsed_json->{'results'}->{'collection1'}->{'posted'};
echo "${title} \n ${posted}\n\n";
?>
</body>
</html>
The api endpoint spits out the following (truncated for length of question):
{
name: "agfc",
lastrunstatus: "success",
lastsuccess: "Fri Jan 17 2014 06:39:54 GMT+0000 (UTC)",
nextrun: "Sat Jan 18 2014 06:39:54 GMT+0000 (UTC)",
frequency: "daily",
newdata: true,
results: {
collection1: [
{
title: {
text: "January 8, 2014 Weekly Waterfowl Report",
href: "http://e2.ma/message/zgkue/nnlu0d"
},
posted: "1/8/2014"
}
]
}
I simply want to pull all of the data from the api endpoint and 'echo' '$title' and '$posted' linking to the attributed url('href') of each of the data points.
I am sure there is an easy way to do it. I am missing something. Thanks for your help.