黄金价格行情接口
每10分钟自动更新黄金价格,包含国内黄金价格,纽约期货黄金价格,伦敦现货黄金价格

接口地址: https://58.linkpc.net/api/huangjin

返回格式: JSON

请求方式: GET

请求示例: https://58.linkpc.net/api/huangjin

请求参数说明:

名称 必填 类型 说明

返回参数说明:

名称 类型 说明

返回示例:

{
"code": 200,
"msg": "成功",
"data": {
"ShanghaiGoldExchange": {
"price": "685.60",
"change": "4.00",
"changePercentage": "0.35%",
"highest": "685.60",
"lowest": "681.16",
"open": "681.16",
"previousSettlement": "683.22",
"updateTime": "02:29:20",
"date": "2025-02-22",
"market": "上海黄金交易所 人民币\/克"
},
"NewYorkCommodityExchange": {
"price": "2951.11",
"change": "-4.99",
"changePercentage": "-0.17%",
"highest": "2964.70",
"lowest": "2930.10",
"open": "2955.70",
"previousSettlement": "2956.10",
"updateTime": "05:59:56",
"date": "2025-02-22",
"market": "美国纽约商品交易所 美元\/盎司"
},
"LondonSpotGoldMarket": {
"price": "2936.17",
"change": "-2.97",
"changePercentage": "-0.10%",
"highest": "2949.64",
"lowest": "2916.66",
"open": "2938.23",
"previousSettlement": "2939.14",
"updateTime": "05:55:00",
"date": "2025-02-22",
"market": "英国伦敦黄金交易市场 美元\/盎司"
}
}
}

错误码格式说明:

名称 类型 说明

代码示例:

                            <?php
header('Content-type: application/json; charset=utf-8');
date_default_timezone_set('PRC');
$url = 'https://58.linkpc.net/api/huangjin';
$type = isset($_GET['type']) ? $_GET['type'] : '';
if ($type == 'json' || $type == 'JSON') {
$result = file_get_contents($url . '?type=json');
echo htmlspecialchars($result);
} else {
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
$contentType = curl_getinfo($ch, CURLINFO_CONTENT_TYPE);
curl_close($ch);

if (strpos($contentType, 'image') !== false) {
header('Content-Type: ' . $contentType);
echo $response;
} elseif (strpos($contentType, 'text') !== false) {
header('Content-Type: ' . $contentType);
echo $response;
} elseif (strpos($contentType, 'application/json') !== false) {
header('Content-Type: application/json');
echo $response;
} else {
header('Content-Type: text/html');
echo $response;
}
}
?>