gpt4 book ai didi

java - Twitter4J sendDirectMessage 返回页面不存在

转载 作者:行者123 更新时间:2023-12-02 01:49:55 25 4
gpt4 key购买 nike

我想开发一个可以发送直接消息的应用程序,如下所示:

public static void sendDirectMessage(Long recipientId, String message){
System.out.print("[Bot] Sending message to @"+recipientId+"... ");
try {
twitter.sendDirectMessage(recipientId, message);
System.out.println("done");
} catch (TwitterException e) {
System.out.println("fail");
e.printStackTrace();
System.err.println("[Error] "+e.getErrorMessage());
}
}

我调用此声明时:

private static String
customer_key = "",
Oth_key = "",
access_token = "",
access_key = "";

private static TwitterBot bot;

public static void main(String[] args) {
try {
bot = new TwitterBot(customer_key, Oth_key, access_token, access_key);
} catch (TwitterException e) {
e.printStackTrace();
} catch (InterruptedException e) {
System.err.println("[Err] "+e.getMessage());
}
bot.sendDirectMessage(bot.getUserData("AbA2L1").getId(), "Message test:!");
}

返回错误:

404:The URI requested is invalid or the resource requested, such as a user, does not exists. Also returned when the requested format is not supported by the requested method.
message - Sorry, that page does not exist.
code - 34

注意:

函数 search()、getHomeTimeline() 和 updateStatus() 可以工作。

我已激活 Twitter 应用程序上的读取、写入和直接消息权限。

抱歉我的英语不好。

最佳答案

它适用于此版本,将其添加到 pom.xml 文件中:

<dependencies>
<!-- https://mvnrepository.com/artifact/org.twitter4j/twitter4j-core -->
<dependency>
<groupId>org.twitter4j</groupId>
<artifactId>twitter4j-core</artifactId>
<version>4.0.7</version>
</dependency>
</dependencies>

祝你好运。

关于java - Twitter4J sendDirectMessage 返回页面不存在,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53119677/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com