2
我使用node.js並使用照片引用字符串並希望獲得對返回的圖像的訪問權限。處理谷歌照片引用以獲取圖像url
我有下面的代碼,正在取回正文中的東西。
locations.forEach(function(loc) {
var photoRef;
if (loc.photos && Array.isArray(loc.photos)) {
photoRef = loc.photos[0].photo_reference;
var url_in = 'https://maps.googleapis.com/maps/api/place/photo?maxwidth=400&photoreference=' + photoRef + '&key=' + key;
request(url_in, function (error, response, body) {
if (!error && response.statusCode == 200) {
console.log(body); // Show the HTML for the Google homepage.
}
});
}
});
我只想得到字符串是圖像的URL。但是我得到的是代表網頁的對象。
任何幫助將不勝感激。
你想要保存圖像,還是隻需要在網上獲取圖像的網址? –
例如:從[此API調用(https://maps.googleapis.com/maps/api/place/photo?maxwidth=400&photoreference=CmRdAAAAHcsAE2aiv5lIxLEo0c9xMUmH-chXoAeq6yrFPw5uy7LdppAMxBmg8_yvG9y9qaXqsH-IrcPsBD6QQvsfZnpml3U5zgh93nTbm5WONnYmutBSltIr9FwuK-awm8l1vyKeEhD9AqZpJwFLIWms2GeZGPR2GhSPp1JyAU_6_s1Im1_oH5tB4IjyXQ&key=API-KEY)到這個[圖像URL] (https://lh3.googleusercontent.com/-B8FWOhhu2_k/VTdYJeFjRhI/AAAAAAAAAD8/JSJamjx4XyA/s1600-w400/) –
@RohinGopalakrishnan我只是想圖像網址在線 – user1907509