无法注册 Twitter Webhook。 {“错误”:[{“代码”:32,“消息”:“无法对您进行身份验证。”}]}

Can not register twitter webhook. {“errors”:[{“code”:32,”message”:”Could not authenticate you.”}]}

我正在尝试为 Twitter webhook 注册一个端点,但它 returns {“errors”:[{“code”:32,“message”:“Could not authenticate you.”}]}

我正在使用 twitter sample request 注册 webhook。这是我的卷曲请求, curl request to register url

curl --request POST --url "https://api.twitter.com/1.1/account_activity/all/:ENV_NAME/webhooks.json?https%3A%2F%2Fd216d0d30d8f.ngrok.io%2Fapi%2F1.0%2Fwebhooks%2Ftwitter" --header "authorization: OAuth oauth_consumer_key="CONSUMER_KEY", oauth_nonce="EhOhXekPMpf", oauth_signature="GvOx3V91BrfWuBuPKUuftYgRgHY%3D", oauth_signature_method="HMAC-SHA1", oauth_timestamp="1597823037", oauth_token="ACCESS_TOKEN", oauth_version="1.0""

我的端点是 运行 在 https 上使用 ngrok 隧道 endpoint running on https using ngrok

我已经从推特上获得了所有要求:

我已尝试使用 angular 和 https mydomain 请求。

//function to register twitter webhook 
registerTwitterWebhook() {

    // authorization in headers
    const headers = new HttpHeaders({
      'authorization': 'OAuth oauth_consumer_key="CONSUMER_KEY",oauth_nonce="UAkSZPWDfmM",oauth_signature="%2FWSSbq4R1eTbGF4X9xg1T1e9sY4%3D",oauth_signature_method="HMAC-SHA1",oauth_timestamp="1597728768",oauth_token="ACCESS_TOKEN",oauth_version="1.0"',
      'Content-Type':  'application/x-www-form-urlencoded'
       })
    const url = 'https://api.twitter.com/1.1/account_activity/all/:ENV_NAME/webhooks.json?url="https%3A%2F%mydomain.com%2Fapi%2F1.0%2Fwebhooks%2Ftwitter"';
    return this.http.post(url, {}, { headers: headers });
}

发送POST请求时显示如下错误 Error chrome web console

请指导我注册 Twitter webhook 的可能解决方案。

谢谢

您尝试从浏览器 运行 获取的代码将无法运行,因为 Twitter 不支持 CORS(这就是错误消息告诉您的内容)。 curl 命令需要为每个 this answer

的 URL 提交使用表单数据