• 主页
  • 如果我想只向单元发送Twitter API V2中[urls]中的[expanded_url],该如何定义?

如果我想只向单元发送Twitter API V2中[urls]中的[expanded_url],该如何定义?

我尝试只收集从推特V2应用程序接口获得的结果的特定部分,有关返回和我尝试使用的脚本的详细信息将放在下面:

结果数据为:

[{"created_at":"2021-06-09T00:31:36.000Z","source":"Twitter Web App","public_metrics":{"retweet_count":0,"reply_count":0,"like_count":2,"quote_count":0},"conversation_id":"1402423096229826562","possibly_sensitive":false,"id":"1402423096229826562","entities":{"urls":[{"start":126,"end":149,"url":"https ://t.co /7PnohIUXzY","expanded_url":"https://stake.com/?iid=sport%3A10916236&modal=bet&c=view","display_url":"stake.com/?iid=sport%3A1…"},{"start":150,"end":173,"url":"https ://t.co /hrBwrm600W","expanded_url":"https://twitter.com/stakehighroller/status/1402423096229826562/photo/1","display_url":"pic.twitter.com/hrBwrm600W"}]},"lang":"en","author_id":"1310800524619386880","reply_settings":"everyone","attachments":{"media_keys":["3_1402423081155526658"]},"text":"ALERT: New high roller bet posted!\nA parlay bet has been placed for $20,000.00 to win $60,480.00.\nTo view this bet or copy it https: //t.co /7PnohIUXzY https ://t .co/hrBwrm600W"}
  {
    "created_at": "2021-06-09T00:31:36.000Z",
    "source": "Twitter Web App",
    "public_metrics": {
      "retweet_count": 0,
      "reply_count": 0,
      "like_count": 2,
      "quote_count": 0
    },
    "conversation_id": "1402423096229826562",
    "possibly_sensitive": false,
    "id": "1402423096229826562",
    "entities": {
      "urls": [
        {
          "start": 126,
          "end": 149,
          "url": "XXXXXXXXXXXXXXXXXXX",
          "expanded_url": "https://stake.com/?iid=sport%3A10916236&modal=bet&c=view",
          "display_url": "stake.com/?iid=sport%3A1…"
        },
        {
          "start": 150,
          "end": 173,
          "url": "YYYYYYYYYYYYYY",
          "expanded_url": "https://twitter.com/stakehighroller/status/1402423096229826562/photo/1",
          "display_url": "pic.twitter.com/hrBwrm600W"
        }
      ]
    },
    "lang": "en",
    "author_id": "1310800524619386880",
    "reply_settings": "everyone",
    "attachments": {
      "media_keys": [
        "3_1402423081155526658"
      ]
    },
    "text": "ALERT: New high roller bet posted!\nA parlay bet has been placed for $20,000.00 to win $60,480.00.\nTo view this bet or copy it XXXXXXXXXXXXXXX YYYYYYYYYYYYYYYY"
  }

我的失败尝试:

  var ss = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("Tweets").getRange("A3");
  var obj_data = JSON.parse(responseApi.getContentText());
  ss.setValue(JSON.stringify(obj_data.data.entities.urls.expanded_url));

期望值结果:

https://stake.com/?iid=sport%3A10916236&modal=bet&c=view

转载请注明出处:http://www.sh-shangchao.com/article/20230526/2249200.html