Good Morning @All,
I am trying to read data from a URL. The data is available in JSON format.
I tried the cms:func. With the post by @trendoman.
But no value is fetched. How do I get the values from the JSON using URL? Any help would be appreciated.
Regards,
GXCPL
P.S.: URL I'm using is "https://api.covid19india.org/raw_data3.json"
I am trying to read data from a URL. The data is available in JSON format.
I tried the cms:func. With the post by @trendoman.
- Code: Select all
<cms:func 'remote_url' url=k_site_link><cms:ignore>
// Sample usage: <cms:call 'remote_url' url="https://www.couchcms.com/" />
</cms:ignore>
<cms:php>
if( extension_loaded('curl') ){
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "<cms:show url />" );
curl_setopt($ch, CURLOPT_USERAGENT, 'CouchCMS <cms:show k_cms_version />');
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$output = curl_exec($ch);
curl_close($ch);
echo $output;
}
</cms:php>
</cms:func>
<cms:capture into='commits' is_json='1' >
<cms:call 'remote_url' url='https://api.github.com/repos/CouchCMS/CouchCMS/commits?per_page=5' />
</cms:capture>
<cms:each commits as='entry' startcount='1'>
<cms:html_encode>
<cms:date date=entry.commit.committer.date format='j M' />: <cms:show entry.commit.message />
</cms:html_encode>
<br/>
</cms:each>
But no value is fetched. How do I get the values from the JSON using URL? Any help would be appreciated.
Regards,
GXCPL
P.S.: URL I'm using is "https://api.covid19india.org/raw_data3.json"