繁体   English   中英

使用Yelp API的Yelp业务ID代码

[英]Yelp business ID code with Yelp API

我有一个必须使用的Yelp评论.csv文件。 它为每个用户和企业提供一个字母数字ID(可能会进行审核)。 我还找不到使用这些代码来找到相关企业的yelp页面的任何方法。 代码看起来像这样...

Capriotti三明治店的“ TR0-w6VoZDAdvFQiq7P2Ug”

“ pLZ9oZM8c6MNbRlg06lBPg”用于冲击式汽车玻璃和色粉

等等...

关于这些业务,我没有其他可以使用的信息。 我确实希望能够使用Yelp的API查找图像URL(我已经可以使用),但是没有运气将.csv文件中的信息转换为API可以使用的东西。

提前致谢。

嘿,我写了这个示例,如果您有运行快递服务器,则可以粘贴并尝试-

// using express
// client - refers to yelp-fusion.client - checkout yelp-fusion NPM

app.get('/reviews', (req, res) => {
  let id = 'TR0-w6VoZDAdvFQiq7P2Ug';
  // id example from your Comment

  client.reviews(id).then(response => {
    // find review from ID given in CSV File:

    let url = new URL(response.jsonBody.reviews[0].url);

    // parse URL using url-parse package, return just pathname

    let bizName = url.pathname.substring(5,url.pathname.length);

    // every yelp pathname begins with /biz/ - use substring to return only biz name

    // now use that bizName to look up business - which will have image url within response:

    client.business(bizName)
    .then(response => {
      console.log(response.jsonBody);
      let featuredImgUrl = response.jsonBody.image_url;
      let photos = response.jsonBody.photos;
      res.json(photos)
    });
  }).catch(e => {
    console.log(e);
    res.json('Error');
  });
})

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM