【问题标题】:Post a Tweet with twitter4j使用 twitter4j 发布推文
【发布时间】:2021-04-11 02:39:15
【问题描述】:

我有一个推特应用程序:

// 承载令牌

// API 密钥

// API 密钥秘密

// 访问令牌:

// 访问令牌秘密:

Read, Write, and Direct Messages 权限

我使用 ConfigurationBuilder 类在 Java 中以编程方式配置 Twitter4J:

ConfigurationBuilder cb = new ConfigurationBuilder();
    cb.setDebugEnabled(true)
            .setOAuthConsumerKey("IX9qalH5azhSk61ZoFMiL83Jg")   // API key
            .setOAuthConsumerSecret("tidoT2GgVZE3B3txDb64tuinlv0wZHbKesX5bNIcjPWpxmcYcs") // API key secret
            .setOAuthAccessToken("1345093646195010258-goY3W4oyqSltGFSUNPwJy8pSjSmfI5") // Access token:
            .setOAuthAccessTokenSecret("ijkpYB8sacVcBdvKHOnh95Y3QRITzD3c4Uq8nUUMLTN8O"); //Access token secret:
    TwitterFactory tf = new TwitterFactory(cb.build());
    return tf.getInstance();

但是当我尝试发布时出现此错误:

401:Authentication credentials (https://dev.twitter.com/pages/auth) were missing or incorrect. Ensure that you have set valid consumer key/secret, access token/secret, and the system clock is in sync.
{"request":"\/1.1\/media\/upload.json","error":"Read-only application cannot POST."}

我从 Ubuntu 服务器发送推文,已经同步 (https://vitux.com/how-to-sync-system-time-with-internet-time-servers-on-ubuntu-20-04/)

root@localhost:~# timedatectl
               Local time: Wed 2021-01-06 08:03:11 UTC
           Universal time: Wed 2021-01-06 08:03:11 UTC
                 RTC time: Wed 2021-01-06 08:03:12    
                Time zone: Etc/UTC (UTC, +0000)       
System clock synchronized: yes                        
              NTP service: active                     
          RTC in local TZ: no 

【问题讨论】:

    标签: java spring-boot oauth twitter-oauth twitter4j


    【解决方案1】:

    从下面的回复中,我认为您使用的是this API

    401:Authentication credentials (https://dev.twitter.com/pages/auth) were missing or incorrect. Ensure that you have set valid consumer key/secret, access token/secret, and the system clock is in sync.
    {"request":"\/1.1\/media\/upload.json","error":"Read-only application cannot POST."}
    

    由于出现如下错误消息,您需要创建一个具有读写权限的 Twitter 应用程序。有关错误消息的更多详细信息,check this

    只读应用程序不能 POST。

    这里是关于app permissions的官方开发者文档。 改变这个: 对此:

    我希望,这已经足够清楚了。

    【讨论】:

      【解决方案2】:
      401:Authentication credentials (https://dev.twitter.com/pages/auth) were missing or incorrect. Ensure that you have set valid consumer key/secret, access token/secret, and the system clock is in sync.
      {"request":"\/1.1\/media\/upload.json","error":"Read-only application cannot POST."}
      

      由于出现如下错误消息,您需要创建一个具有读写权限的 Twitter 应用程序。有关错误消息的更多详细信息,请查看此处。

      【讨论】:

        猜你喜欢
        • 2013-07-06
        • 1970-01-01
        • 1970-01-01
        • 2012-03-28
        • 2015-05-27
        • 2011-06-05
        • 2015-08-10
        • 1970-01-01
        • 2019-06-05
        相关资源
        最近更新 更多