簡體   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