我使用 Google Places Photos Api,我想通过 placeid 或城市标题获取所选城市的景点图像。
我尝试了两种方法:
1. fe 我发送请求(使用 London placeid)
https://maps.googleapis.com/maps/api/place/details/json?placeid=ChIJdd4hrwug2EcRmSrV3Vo6llI&key=API_KEY
从响应中获取位置
"lat": 51.5073509
"lng": -0.1277583
下一步是请求
https://maps.googleapis.com/maps/api/place/radarsearch/json?location=51.5073509,-0.1277583&radius=5000&types=park|church|cafe|food|bar|night_club|stadium|store&keyword=&key=API_KEY
响应包含许多带有 placeid 的对象,我将其用于新请求,例如 first
https://maps.googleapis.com/maps/api/place/details/json?placeid=ChIJ1eu1vwgIdkgRwjsifpZERQc&key=API_KEY
响应包含 photo_reference 对象,它是我的图像源的一部分
https://maps.googleapis.com/maps/api/place/photo?photoreference=CoQBcwAAAMLCk4X_WMliqIfISe-mgxRadycuzApodVcaCrTMGP6wQXJaquATedXMkvnjuLAfTG9xzBYQfSNm3iXV07wxHr_X_WDhfjz_yQjmqCYlKwYwK5hH-nl9qi-4ZZqKKtFuphFEY8ka25GYN2sTNMdd0v99j7YCzpR-lHJnl0zA9QoPEhBA5CnCgElBAU7Z92VTShg2GhQUes4fTRKiJlW6rYKYEaNilauWaA&key=API_KEY&maxwidth=1200
这不是伦敦最好的照片......
2. 使用带有参数的文本搜索 query=sights+in+London
https://maps.googleapis.com/maps/api/place/textsearch/json?query=sights+in+London&key=API_KEY
此请求返回包含 photo_reference 对象的响应。最后请求是
https://maps.googleapis.com/maps/api/place/photo?photoreference=CnRnAAAAlLsg47UJRPVLdM8_sUbeLSia70EJ_mTisVDfCDTVUYNXl-35BGqzRARtq-Lt1CNcBWy3sKigfBVuF0iCr9-xqp1khK2l5JV3806LKvZrHJCaONYW35UBxxIIwxvxV-df4I4hg6f_zgeeIkWXGSYQhhIQNGYJl0fvHb3HslymbhH1thoUdLhGe8rJVCnyl_y0xAagzkFWs-Y&key=API_KEY&maxwidth=1200
我怎样才能得到这样的图像