如何使用 pinterest-node-api 进行图钉搜索?

问题描述 投票:0回答:1
import Pinterest from "pinterest-node-api";
const client = new Pinterest('pina_AMAS3KIWABUBCAA');

  try {
    // Search for pins with the keyword
    const res = await client.request('/pins', {
      method: 'GET',
      params: {
        query: `${keyword} ${modifier}`,
        fields: 'id,note,image'
      }
    });
    const pins = res.data;
  
    // Comment on each pin
    for await (const pin of pins) {
      await client.comment(pin.id, variation);
      console.log(`Commented on pin: https://pinterest.com/pin/${pin.id}`);
    }
  } catch (error) {
    console.error(`Failed to search for or comment on pins. Error: ${error.message}`);
  }

我明白了

client.request is not a function

我正在尝试执行 API 调用以按关键字在全球范围内搜索引脚。

他们页面上的文档没有给我太多信心,因为没有一个例子有效。

javascript node.js pinterest
1个回答
0
投票
   // Search for pins with the keyword
    const searchUrl = `https://api.pinterest.com/v5/search/pins?query=${encodeURIComponent(search)}&topic_based=true`;
    const res = await fetch(searchUrl, {
      headers: {
        'Authorization': `Bearer ${key}`,
      },
    });

    const pins = (await res.json()).items;
© www.soinside.com 2019 - 2024. All rights reserved.