首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >使用Yelp API的Yelp业务ID代码

使用Yelp API的Yelp业务ID代码
EN

Stack Overflow用户
提问于 2018-03-18 00:32:44
回答 1查看 433关注 0票数 0

我有一个.csv文件的点评,我必须使用。它为每个用户和企业提供了一个字母数字id (可能是评论)。我还没有找到任何方法来使用这些代码来定位相关业务的yelp页面。代码是这样的..。

Capriotti's三明治店的“TR0-w6VoZDAdvFqq7P2Ug”

"pLZ9oZM8c6MNbRlg06lBPg“用于冲击汽车玻璃和着色

等等。

我没有任何关于这些业务的其他信息,我可能会使用。我真的希望能够使用Yelp的应用程序接口来查找图像URL(我已经能够使用它了),但是还没有将我的.csv文件中的信息转换成API可以使用的东西。

提前谢谢。

EN

回答 1

Stack Overflow用户

发布于 2018-03-18 02:44:00

嘿,我写了这个例子,如果你有一个正在运行的express服务器,你可以粘贴并试用它-

代码语言:javascript
运行
复制
// 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');
  });
})
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/49339252

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档