本文整理汇总了Java中org.springframework.social.twitter.api.TwitterProfile类的典型用法代码示例。如果您正苦于以下问题:Java TwitterProfile类的具体用法?Java TwitterProfile怎么用?Java TwitterProfile使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
TwitterProfile类属于org.springframework.social.twitter.api包,在下文中一共展示了TwitterProfile类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: findOrCreate
import org.springframework.social.twitter.api.TwitterProfile; //导入依赖的package包/类
private UserEntity findOrCreate(final TwitterProfile twitterProfile) {
UserEntity user = userRepository.findUserByTwitterId(twitterProfile.getId() + "");
if (user != null) {
return user;
}
user = new UserEntity();
user.setCreatedDate(twitterProfile.getCreatedDate());
user.setDescription(twitterProfile.getDescription());
user.setLocation(twitterProfile.getLocation());
user.setName(twitterProfile.getName());
user.setProfileUrl(twitterProfile.getProfileUrl());
user.setProfilImageUrl(twitterProfile.getProfileImageUrl());
user.setScreenName(twitterProfile.getScreenName());
user.setTwitterId(twitterProfile.getId() + "");
user = userRepository.save(user);
return user;
}
示例2: getRainUsernames
import org.springframework.social.twitter.api.TwitterProfile; //导入依赖的package包/类
/**
* parse user names in a tip rain command
* @param userNames
* @return
*/
List<String> getRainUsernames(String userNames){
String[] splitted = userNames.split("@");
String userName;
List<String> result = new ArrayList<String>();
for (String part : splitted){
if (part.length() > 0){
userName = part.trim();
//verify if user exist
TwitterProfile profile = twitterTemplate.userOperations().getUserProfile(userName);
if (profile!=null){
result.add(userName);
}
}
}
return result;
}
示例3: helloTwitter
import org.springframework.social.twitter.api.TwitterProfile; //导入依赖的package包/类
/**
* /connect/twitter path is handled by ConnectController.
* It will kick off the OAuth authorization code flow. -->
* @param model
* @return
*/
@RequestMapping(method= RequestMethod.GET)
public String helloTwitter(Model model) {
if (connectionRepository.findPrimaryConnection(Twitter.class) == null) {
return "redirect:/connect/twitter";
}
Set<String> favoriteTexts = getFavoriteTexts();
Map<NotionNodeData, Long> preferenceToProbability = analysisProcessing.findKeywordsInSentences(favoriteTexts);
List<Integer> userPreferenceIds = preferenceToProbability.entrySet().stream()
.map(e -> e.getKey().getId().intValue())
.collect(Collectors.toList());
int[] userPrefIds = convertListToArray(userPreferenceIds);
Map<Long, List<Integer>> offerIdToRelatedNodeIds = offerDataService.findAll().stream()
.collect(Collectors.toMap(o -> o.getId(),
o -> o.getRelatedNodes().stream()
.map(n -> n.getId().intValue())
.collect(Collectors.toList())));
Map<Long, Integer> offerIdToMaxResult = offerIdToRelatedNodeIds.entrySet().stream()
.collect(Collectors.toMap(e -> e.getKey(),
e -> maxSatSolver.iloscDopasowan(userPrefIds, convertListToArray(e.getValue()))))
.entrySet().stream()
.sorted((e1, e2) -> e2.getValue().compareTo(e1.getValue()))
.collect(Collectors.toMap(e -> e.getKey(),
e -> e.getValue(), (e1, e2) -> e2, LinkedHashMap::new));
model.addAttribute(twitter.userOperations().getUserProfile());
CursoredList<TwitterProfile> friends = twitter.friendOperations().getFriends();
model.addAttribute("friends", friends);
model.addAttribute("preferences", preferenceToProbability);
model.addAttribute("offers", offerIdToMaxResult);
return "html/hello";
}
示例4: saveEs
import org.springframework.social.twitter.api.TwitterProfile; //导入依赖的package包/类
private TweetEsEntity saveEs(final Tweet tweetEntity) {
final TwitterProfile twitterProfile = tweetEntity.getUser();
final UserEsEntity user = new UserEsEntity();
user.setCreatedDate(twitterProfile.getCreatedDate());
user.setDescription(twitterProfile.getDescription());
user.setLocation(twitterProfile.getLocation());
user.setName(twitterProfile.getName());
user.setProfileUrl(twitterProfile.getProfileUrl());
user.setProfilImageUrl(twitterProfile.getProfileImageUrl());
user.setScreenName(twitterProfile.getScreenName());
user.setTwitterId(twitterProfile.getId() + "");
TweetEsEntity esTweet = new TweetEsEntity();
esTweet.setCreatedAt(tweetEntity.getCreatedAt());
esTweet.setLanguageCode(tweetEntity.getLanguageCode());
esTweet.setSource(tweetEntity.getSource());
esTweet.setText(tweetEntity.getText());
esTweet.setUser(user);
if (tweetEsRepository != null) {
esTweet = tweetEsRepository.save(esTweet);
return esTweet;
}
return null;
}
示例5: User
import org.springframework.social.twitter.api.TwitterProfile; //导入依赖的package包/类
public User(TwitterProfile twitterProfile) {
this.profileId = twitterProfile.getId();
this.createdDate = twitterProfile.getCreatedDate();
this.screenName = twitterProfile.getScreenName();
this.name = twitterProfile.getName();
this.url = twitterProfile.getUrl();
this.description = twitterProfile.getDescription();
this.location = twitterProfile.getLocation();
this.profileImageUrl = twitterProfile.getProfileImageUrl();
this.followerCount = twitterProfile.getFollowersCount();
this.followsCount = twitterProfile.getFriendsCount();
}
示例6: validateUserExists
import org.springframework.social.twitter.api.TwitterProfile; //导入依赖的package包/类
private String validateUserExists(String toUserName) {
try {
TwitterProfile profile = twitterTemplate.userOperations().getUserProfile(toUserName);
if (profile != null) {
logger.info("user found : "+ profile.getScreenName());
return profile.getScreenName();
}
else return null;
} catch (ResourceNotFoundException e){
return null;
}
}
示例7: findRandomFollower
import org.springframework.social.twitter.api.TwitterProfile; //导入依赖的package包/类
/**
* select a random follower of a given twitterTemplate user
* @param fromUser
* @return
*/
String findRandomFollower(long fromUser) {
logger.debug("Searching a random follower of " + fromUser);
List<TwitterProfile> followers = twitterTemplate.friendOperations().getFollowers(fromUser);
Random generator = new Random();
int choseOne = generator.nextInt(followers.size());
TwitterProfile chosenProfile = followers.get(choseOne);
logger.debug("Found : @" + chosenProfile.getScreenName());
return chosenProfile.getScreenName();
}
示例8: User
import org.springframework.social.twitter.api.TwitterProfile; //导入依赖的package包/类
public User(TwitterProfile user) {
this.userId = user.getId();
this.user = user.getScreenName();
this.name = user.getName();
createdDate = user.getCreatedDate();
followers = user.getFollowersCount();
friends = user.getFriendsCount();
url = user.getUrl();
image = user.getProfileImageUrl();
language = user.getLanguage();
}
示例9: getUserProfile
import org.springframework.social.twitter.api.TwitterProfile; //导入依赖的package包/类
@RequestMapping(value = "/profile/{twitterUser}")
public TwitterProfile getUserProfile(@PathVariable String twitterUser) {
return twitterService.getUserProfile(twitterUser);
}
示例10: getUserProfile
import org.springframework.social.twitter.api.TwitterProfile; //导入依赖的package包/类
/**
*
* @param twitterUser
* @return
*/
public TwitterProfile getUserProfile(String twitterUser) {
UserOperations userOperations = twitter.userOperations();
TwitterProfile userProfile = userOperations.getUserProfile(twitterUser);
return userProfile;
}