如何在Zapier代码中制作推文 [英] How do I make a Tweet in Zapier code

查看:208
本文介绍了如何在Zapier代码中制作推文的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

以下内容在Zapier代码行动中无效。

The following does not work in the "Code by Zapier" Action.

fetch('https://api.twitter.com/1.1/statuses/update.json?status=' +encodeURIComponent(textToTweet))
  .then(function(res) {
    return res.json();
  })
  .then(function(json) {
    callback(null, json);
  })
  .catch(callback);

但是,我得到以下内容。

However, I get the following.

errors:
    message:
    Bad Authentication data.
    code:
    215

需要做哪些额外的身份验证? Twitter帐户已经连接到Zapier,或者这无关紧要?

What additional authentication does one need to do? The Twitter account is already connected to Zapier, or does that not matter?

更新:现在每个反馈低于以下代码给我一个89:无效或过期的令牌

UPDATE: per feedback below the following code now gives me an 89: invalid or expired token

fetch('https://api.twitter.com/1.1/statuses/update.json?status=' +encodeURIComponent(textToTweet), { 
  headers: {
        Authorization: 'Bearer ACCESS_TOKEN_BEGINSWITH_OWNERID'
  }
})
  .then...............


推荐答案

如果您知道咒语,这是相当简单的:

This is fairly straightforward if you know the incantations:


  1. https://dev.twitter.com/oauth/overview/application-owner-access-tokens

  2. 在您的 fetch()电话中添加授权:Bearer< yourtoken> 标头。

  1. Get a token from https://dev.twitter.com/oauth/overview/application-owner-access-tokens.
  2. Add a Authorization: Bearer <yourtoken> header to your fetch() call.

你应该好好去!

这篇关于如何在Zapier代码中制作推文的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆