Twitter4j ID 到数组
Twitter4j IDs to Array
我正在尝试比较两个列表。一个列表包含我在 Twitter 上关注的每个人,另一个是关注我的每个人。我不知道该怎么做,因为 .getFollowersIDs 和 .getFriendsIDs 是 ID 类型。我查过这个,但我不明白如何比较这种类型的结果。我试着把它们当作数组来对待,但 Eclipse 不喜欢那样……
http://twitter4j.org/javadoc/twitter4j/IDs.html
The type of the expression must be an array type but it resolved to IDs
package com.follow3d.rob;
import java.util.List;
import twitter4j.*;
import twitter4j.conf.*;
public class Follow3d {
public static void main(String[] args) {
ConfigurationBuilder cb = new ConfigurationBuilder();
cb.setDebugEnabled(true).setOAuthConsumerKey("xxxxxx")
.setOAuthConsumerSecret("xxxxxx")
.setOAuthAccessToken("xxxxxx")
.setOAuthAccessTokenSecret("xxxxxx");
TwitterFactory tf = new TwitterFactory(cb.build());
Twitter twitter = tf.getInstance();
try {
long ID = twitter.getId();//Personal Twitter ID.
IDs FOLLOWERS = twitter.getFollowersIDs(-1);//Numeric Array of every user that follows me.
IDs FOLLOWING = twitter.getFriendsIDs(-1);//Numeric Array of every user I am following.
while (FOLLOWING.hasNext() == true)
{
int counter = 0;
if (FOLLOWING[counter] != FOLLOWERS[counter])//ERROR HERE.
}
} catch (TwitterException name) {
System.out.println("You don't have internet connection.");
}
}
}
如 documentation 中所述,FOLLOWERS 和 FOLLOWING 是 IDs
类型(不是数组),因此我们不能通过 index
引用其中的任何元素。
如果我们需要比较关注者和关注的用户id,我们需要使用IDs
class的getIDs()
方法(即FOLLOWERS和FOLLOWING objects
)并遍历它们。此外,不是使用 while
循环进行迭代(如示例所示),我们需要为 FOLLOWERS 数组的每个元素迭代 FOLLOWING 数组以查看 id 是否存在。
IDs::getIDs()
给你一个 long[]
。我想这就是你想要的。
我正在尝试比较两个列表。一个列表包含我在 Twitter 上关注的每个人,另一个是关注我的每个人。我不知道该怎么做,因为 .getFollowersIDs 和 .getFriendsIDs 是 ID 类型。我查过这个,但我不明白如何比较这种类型的结果。我试着把它们当作数组来对待,但 Eclipse 不喜欢那样…… http://twitter4j.org/javadoc/twitter4j/IDs.html
The type of the expression must be an array type but it resolved to IDs
package com.follow3d.rob;
import java.util.List;
import twitter4j.*;
import twitter4j.conf.*;
public class Follow3d {
public static void main(String[] args) {
ConfigurationBuilder cb = new ConfigurationBuilder();
cb.setDebugEnabled(true).setOAuthConsumerKey("xxxxxx")
.setOAuthConsumerSecret("xxxxxx")
.setOAuthAccessToken("xxxxxx")
.setOAuthAccessTokenSecret("xxxxxx");
TwitterFactory tf = new TwitterFactory(cb.build());
Twitter twitter = tf.getInstance();
try {
long ID = twitter.getId();//Personal Twitter ID.
IDs FOLLOWERS = twitter.getFollowersIDs(-1);//Numeric Array of every user that follows me.
IDs FOLLOWING = twitter.getFriendsIDs(-1);//Numeric Array of every user I am following.
while (FOLLOWING.hasNext() == true)
{
int counter = 0;
if (FOLLOWING[counter] != FOLLOWERS[counter])//ERROR HERE.
}
} catch (TwitterException name) {
System.out.println("You don't have internet connection.");
}
}
}
如 documentation 中所述,FOLLOWERS 和 FOLLOWING 是 IDs
类型(不是数组),因此我们不能通过 index
引用其中的任何元素。
如果我们需要比较关注者和关注的用户id,我们需要使用IDs
class的getIDs()
方法(即FOLLOWERS和FOLLOWING objects
)并遍历它们。此外,不是使用 while
循环进行迭代(如示例所示),我们需要为 FOLLOWERS 数组的每个元素迭代 FOLLOWING 数组以查看 id 是否存在。
IDs::getIDs()
给你一个 long[]
。我想这就是你想要的。