首页 国家数据 国家数据示例代码 获取国家详情[PHP]

获取国家详情示例代码[PHP]

作者: 阅读数:1595 上传时间:2019-07-15

获取国家详情

<?php
//获取国家地区详情
require_once 'curl.func.php';

$appkey = 'your_appkey_here';//你的appkey
$name= '中国';
$countryid='218';


$url = "https://api.jisuapi.com/country/detail?appkey=$appkey&name=$name&countryid=$countryid";
$result = curlOpen($url, ['ssl'=>true]);
$jsonarr = json_decode($result, true);
if($jsonarr['status'] != 0)
{
    echo $jsonarr['msg'];
    exit();
}
$country = $jsonarr['result'];     
 echo $country['countryid'].' '.$country['name'].' '.$country['cname'].' '.$country['ename'].' '.$country['capital'].' '.$country['nationalanthem'].' '.$country['currency'].' '.$country['code'].' '.$country['language'].' '.$country['area'].' '.$country['timezone'].' '.$country['gdp'].' '.$country['avggdp'].' '.$country['areacode'].' '.$country['domain'].' '.$country['continent'].' '.$country['waterrate'].' '.$country['mainreligion'].' '.$country['maincity'].' '.$country['nationalday'].' '.$country['political'].' '.$country['leader'].' '.$country['population'].' '.$country['populationdensity'].' '.$country['mainethnic'].' '.$country['roadaccess'].' '.$country['mainuniversity'].' '.$country['nationalflag'].' '.$country['humanindex'].' '.$country['largestcity'].' '.$country['nationalflower'].' '.$country['geoposition'].' '.$country['foreignname'].' '.$country['nationalmotto'].' '.$country['govresidence'].' '.$country['climate'].' '.$country['iscountry"'].' '.$country['zimu'].' '.$country['代表事物'].' '.$country['代表人物'].' '.$country['文化思想'].' '.$country['通用文字'].'
';