简体   繁体   English

使用Yelp API的Yelp业务ID代码

[英]Yelp business ID code with Yelp API

I have a .csv file of yelp reviews that I must use. 我有一个必须使用的Yelp评论.csv文件。 It gives an alphanumeric id for each user and business(possibly review). 它为每个用户和企业提供一个字母数字ID(可能会进行审核)。 I haven't been able to find any way of using these codes to locate the associated business' yelp page. 我还找不到使用这些代码来找到相关企业的yelp页面的任何方法。 The codes look like this... 代码看起来像这样...

"TR0-w6VoZDAdvFQiq7P2Ug" for Capriotti's Sandwich Shop Capriotti三明治店的“ TR0-w6VoZDAdvFQiq7P2Ug”

"pLZ9oZM8c6MNbRlg06lBPg" for Impact Auto Glass & Tint “ pLZ9oZM8c6MNbRlg06lBPg”用于冲击式汽车玻璃和色粉

etc... 等等...

I don't have any other info on these businesses that I could potentially use. 关于这些业务,我没有其他可以使用的信息。 I really want to be able to use Yelp's API to find image URLs (which I have been able to use), but haven't had any luck translating the info in my .csv file to something the API can use. 我确实希望能够使用Yelp的API查找图像URL(我已经可以使用),但是没有运气将.csv文件中的信息转换为API可以使用的东西。

Thanks in advance. 提前致谢。

Hey I wrote up this example, if you have an express server running you can paste in and try it out - 嘿,我写了这个示例,如果您有运行快递服务器,则可以粘贴并尝试-

// 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