处理2:发布到Facebook错误"类型帖子不明确"

use*_*891 1 java processing facebook facebook-graph-api temboo

使用Processing和Temboo库更新状态到Facebook,但我遇到以下错误:"类型Post是模棱两可的"这条线似乎是突出显示的原因"Post postChoreo = new Post(session);".关于如何解决这个问题的任何建议都会非常好.

import com.temboo.core.*;
import com.temboo.Library.Facebook.Publishing.*;

// Create a session using your Temboo account application details
TembooSession session = new TembooSession("dylabaloo", "myFirstApp",    
"xxxxxxxxxxxxxxxxxxxx");

 void setup() {
// Run the Post Choreo function
runPostChoreo();
}

void runPostChoreo() {
// Create the Choreo object using your Temboo session
Post postChoreo = new Post(session);

 // Set inputs
postChoreo.setAccessToken("xxxxxxxxxxxxxxxxxx");
postChoreo.setMessage("Your High Score is:");

// Run the Choreo and store the results
PostResultSet postResults = postChoreo.run();

// Print results
println(postResults.getResponse());

}
Run Code Online (Sandbox Code Playgroud)

moo*_*ter 5

只是看看代码和你得到的错误,我想Post类可以存在于com.temboo.core.*包中,也可以存在于com.temboo.Library.Facebook.Publishing.*包中或同一个包中,在哪里写你的课.

我猜您正在尝试使用Facebook发布Post,因此您应该将Post导入为以下内容以避免歧义.import com.temboo.Library.Facebook.Publishing.Post;

使用通配符导入不是一个好主意.其一,您将遇到此类问题,因为使用通配符导入的多个包中可能存在相同的类名.其次,进口的必要类太多了.第三,这不是一个好的编码实践.

大多数IDE,尤其是所有基于eclispe的IDE,都提供了轻松的快捷方式来组织导入(如Windows的Ctrl-Shift-O),这可以帮助您组织导入并避免此类问题.