gpt4 book ai didi

javascript - 使用php从URL获取json数据

转载 作者:可可西里 更新时间:2023-11-01 00:43:06 25 4
gpt4 key购买 nike

这里我尝试从下面的url获取json数据

https://www.flickr.com/services/api/render?method=flickr.places.find&api_key=xxxxx&query=$search_data&format=json&nojsoncallback=1

包含以下我想根据上面的链接得到的信息

{
"places": {
"place": [
{
"place_id": "Dm5SiT1TULMEIMYN",
"woeid": "2295402",
"latitude": 23.03,
"longitude": 72.591,
"place_url": "/India/Gujarat/Ahmedabad",
"place_type": "locality",
"place_type_id": 7,
"timezone": "Asia/Kolkata",
"_content": "Ahmedabad, Gujarat, India",
"woe_name": "Ahmedabad"
},
{
"place_id": "mz1zSK1YUrJTfvUrOA",
"woeid": "90883450",
"latitude": 23.027,
"longitude": 72.57,
"place_url": "/India/Gujarat",
"place_type": "locality",
"place_type_id": 7,
"timezone": "Asia/Kolkata",
"_content": "Ahmedabad, India",
"woe_name": "Ahmedabad"
}
],
"query": "Ahmedabad, Gujarat, India",
"total": 2
},
"stat": "ok"
}

但这里的问题是这个链接返回 null 我正在使用以下 php 代码

$json_array = file_get_contents("https://www.flickr.com/services/api/render?method=flickr.places.find&api_key=xxxxx&query=Ahmedabad,%20Gujarat,%20India&format=json&nojsoncallback=1");
$json_array = iconv('UTF-16', 'UTF-8', $json_array);
$json_data=json_decode($json_array,true);
print_r($json_data);

最佳答案

你的电话是错误的。正确的应该是

https://api.flickr.com/services/rest/?method=flickr.places.find&.....

关于javascript - 使用php从URL获取json数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28405677/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com