當前位置: 首頁>>代碼示例>>Java>>正文


Java LinkedInApiClient類代碼示例

本文整理匯總了Java中com.google.code.linkedinapi.client.LinkedInApiClient的典型用法代碼示例。如果您正苦於以下問題:Java LinkedInApiClient類的具體用法?Java LinkedInApiClient怎麽用?Java LinkedInApiClient使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


LinkedInApiClient類屬於com.google.code.linkedinapi.client包,在下文中一共展示了LinkedInApiClient類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: registerUser

import com.google.code.linkedinapi.client.LinkedInApiClient; //導入依賴的package包/類
private String registerUser(HttpSession session, Map<String, Object> model, LinkedInSettings settings) {
    LinkedInApiClient client = helper.getClient(settings);

    User user = new User();
    user.setLinkedInSettings(settings);

    Person person = client.getProfileForCurrentUser(LinkedInHelper.PROFILE_FIELDS);
    helper.fillUserData(user, person);

    user.setUsername(user.getNames().toLowerCase().replace(' ', '.'));
    user.setExternalAuthId(person.getId());
    user.getProfile().setLanguage(Language.EN);

    session.setAttribute(ExternalAuthenticationController.EXTERNAL_USER_DATA, user);
    model.put("user", user);
    return ExternalAuthenticationController.EXTERNAL_REGISTRATION_VIEW;
}
 
開發者ID:Glamdring,項目名稱:welshare,代碼行數:18,代碼來源:LinkedInController.java

示例2: getUserMessages

import com.google.code.linkedinapi.client.LinkedInApiClient; //導入依賴的package包/類
@Override
public List<Message> getUserMessages(Message lastMessage, User user) {
    if (!isServiceEnabled(user)) {
        return Collections.emptyList();
    }

    try {
        LinkedInApiClient client = helper.getClient(user);
        Updates updates = null;
        if (lastMessage == null) {
            updates = client.getUserUpdates(LinkedInHelper.NETWORK_UPDATE_TYPES, 0, messagesPerFetch)
                    .getUpdates();
        } else {
            updates = client.getUserUpdates(LinkedInHelper.NETWORK_UPDATE_TYPES, 0, messagesPerFetch,
                    null, lastMessage.getDateTime().toDate()).getUpdates();
        }
        List<Message> messages = updatesToMessages(updates.getUpdateList());
        return messages;
    } catch (LinkedInApiClientException ex) {
        handleException("Problem getting linkedIn user messages", ex, user);
        return Collections.emptyList();
    }
}
 
開發者ID:Glamdring,項目名稱:welshare,代碼行數:24,代碼來源:LinkedInService.java

示例3: getUserDetails

import com.google.code.linkedinapi.client.LinkedInApiClient; //導入依賴的package包/類
@Override
public UserDetails getUserDetails(String externalUserId, User currentUser) {
    if (!isServiceEnabled(currentUser)) {
        return null;
    }

    LinkedInApiClient client = helper.getClient(currentUser);
    try {
        Person person = client.getProfileById(getLinkedInId(externalUserId), LinkedInHelper.PROFILE_FIELDS);
        User user = new User();
        helper.fillUserData(user, person);
        return new UserDetails(user);
    } catch (LinkedInApiClientException ex) {
        handleException("Problem getting linkedIn user", ex, currentUser);
        return null;
    }
}
 
開發者ID:Glamdring,項目名稱:welshare,代碼行數:18,代碼來源:LinkedInService.java

示例4: getIncomingMessages

import com.google.code.linkedinapi.client.LinkedInApiClient; //導入依賴的package包/類
@Override
public List<Message> getIncomingMessages(Message lastMessage, User user) {
    if (!isServiceEnabled(user)) {
        return Collections.emptyList();
    }
    LinkedInApiClient client = helper.getClient(user);
    try {
        Updates updates = client.getNetworkUpdates(LinkedInHelper.NETWORK_UPDATE_TYPES, 0,
                messagesPerFetch, lastMessage.getDateTime().plusSeconds(1).toDate(), new Date()).getUpdates();
        if (updates == null) {
            return Collections.emptyList();
        }

        return updatesToMessages(updates.getUpdateList());
    } catch (LinkedInApiClientException ex) {
        handleException("Problem getting incoming LinkedIn messages", ex, user);
        return Collections.emptyList();
    }
}
 
開發者ID:Glamdring,項目名稱:welshare,代碼行數:20,代碼來源:LinkedInService.java

示例5: getLikers

import com.google.code.linkedinapi.client.LinkedInApiClient; //導入依賴的package包/類
@Override
public List<User> getLikers(String externalMessageId, User user) {
    if (!isServiceEnabled(user)) {
        return Collections.emptyList();
    }
    LinkedInApiClient client = helper.getClient(user);
    try {
        Likes likes = client.getNetworkUpdateLikes(getLinkedInId(externalMessageId));
        if (likes != null) {
            List<User> result = new ArrayList<User>(likes.getTotal().intValue());
            for (Like like : likes.getLikeList()) {
                User liker = new User();
                helper.fillUserData(liker, like.getPerson());
                result.add(liker);
            }
            return result;
        } else {
            return Collections.emptyList();
        }
    } catch (LinkedInApiClientException ex) {
        handleException("Problem getting likers of message with id=" + externalMessageId, ex, user);
        return Collections.emptyList();
    }
}
 
開發者ID:Glamdring,項目名稱:welshare,代碼行數:25,代碼來源:LinkedInService.java

示例6: getMessagesOfUser

import com.google.code.linkedinapi.client.LinkedInApiClient; //導入依賴的package包/類
@Override
public List<Message> getMessagesOfUser(String externalId, User user) {
    if (!isServiceEnabled(user)) {
        return Collections.emptyList();
    }

    LinkedInApiClient client = helper.getClient(user);

    try {
        Network nw = client.getUserUpdates(externalId, LinkedInHelper.NETWORK_UPDATE_TYPES, 0,
                messagesPerFetch);
        return updatesToMessages(nw.getUpdates().getUpdateList());
    } catch (LinkedInApiClientException ex) {
        handleException("Problem getting updates of user with id=" + externalId, ex, user);
        return Collections.emptyList();
    }
}
 
開發者ID:Glamdring,項目名稱:welshare,代碼行數:18,代碼來源:LinkedInService.java

示例7: share

import com.google.code.linkedinapi.client.LinkedInApiClient; //導入依賴的package包/類
@Override
@Async
@SqlTransactional
public void share(Message message, User user) {
    if (!isServiceEnabled(user)) {
        return;
    }
    try {
        LinkedInApiClient client = helper.getClient(user);

        List<String> urls = WebUtils.extractUrls(message.getText());
        String messageText = getMessageText(message, user);
        // if there are urls, but no picture
        if (!urls.isEmpty() || message.getPictureCount() > 0) {
            String url = null;
            String imageUrl = null;
            if (!urls.isEmpty()) {
                url = urls.get(0);
                VideoData vd = helper.getVideoData(url);
                if (vd != null) {
                    imageUrl = vd.getPicture();
                }
            } else {
                url = message.getPictures().get(0).getPublicUrl();
                imageUrl = WebUtils.addSuffix(message.getPictures().get(0).getPath(),
                        PictureSize.LARGE.getSuffix());
            }
            client.postShare(messageText, null, url, imageUrl, VisibilityType.ANYONE);
        } else {
            client.postNetworkUpdate(messageText);
        }
    } catch (LinkedInApiClientException ex) {
        handleException("Problem sharing message", ex, user);
    }
}
 
開發者ID:Glamdring,項目名稱:welshare,代碼行數:36,代碼來源:LinkedInService.java

示例8: like

import com.google.code.linkedinapi.client.LinkedInApiClient; //導入依賴的package包/類
@Override
@Async
public void like(String originalMessageId, ResharingDetails details, User user) {
    if (!isServiceEnabled(user)) {
        return;
    }
    LinkedInApiClient client = helper.getClient(user);
    String linkedInId = getLinkedInId(originalMessageId);
    try {
        client.likePost(linkedInId);
    } catch (LinkedInApiClientException ex) {
        handleException("Problem liking a LinkedIn update", ex, user);
    }
}
 
開發者ID:Glamdring,項目名稱:welshare,代碼行數:15,代碼來源:LinkedInService.java

示例9: unlike

import com.google.code.linkedinapi.client.LinkedInApiClient; //導入依賴的package包/類
@Override
@Async
public void unlike(String originalMessageId, User user) {
    if (!isServiceEnabled(user)) {
        return;
    }
    LinkedInApiClient client = helper.getClient(user);
    String linkedInId = getLinkedInId(originalMessageId);
    try {
        client.unlikePost(linkedInId);
    } catch (LinkedInApiClientException ex) {
        handleException("Problme unliking a LinkedIn", ex, user);
    }

}
 
開發者ID:Glamdring,項目名稱:welshare,代碼行數:16,代碼來源:LinkedInService.java

示例10: reply

import com.google.code.linkedinapi.client.LinkedInApiClient; //導入依賴的package包/類
@Override
@Async
@SqlTransactional
public void reply(String originalMessageId, Message message) {
    if (!isServiceEnabled(message.getAuthor())) {
        return;
    }
    try {
        LinkedInApiClient client = helper.getClient(message.getAuthor());
        client.postComment(getLinkedInId(originalMessageId), message.getTextWithPictureUrls());
    } catch (LinkedInApiClientException ex) {
        handleException("Problem replying to a linkedIn message", ex, message.getAuthor());
    }
}
 
開發者ID:Glamdring,項目名稱:welshare,代碼行數:15,代碼來源:LinkedInService.java

示例11: getReplies

import com.google.code.linkedinapi.client.LinkedInApiClient; //導入依賴的package包/類
@Override
public List<Message> getReplies(String originalMessageId, User user) {
    if (!isServiceEnabled(user)) {
        return Collections.emptyList();
    }

    LinkedInApiClient client = helper.getClient(user);
    try {
        UpdateComments updateComments = client.getNetworkUpdateComments(getLinkedInId(originalMessageId));
        List<UpdateComment> comments = updateComments.getUpdateCommentList();
        List<Message> result = new ArrayList<Message>(comments.size());
        for (UpdateComment comment : comments) {
            Message msg = new Message();
            msg.setText(comment.getComment());
            msg.setDateTime(new DateTime(comment.getTimestamp()));
            msg.getData().setExternalId(LinkedInHelper.PUBLIC_ID_PREFIX + comment.getId());
            User author = new User();
            helper.fillUserData(user, comment.getPerson());
            msg.setAuthor(author);
            result.add(msg);
        }
        return result;
    } catch (LinkedInApiClientException ex) {
        handleException("Problem getting linkedIn replies", ex, user);
        return Collections.emptyList();
    }
}
 
開發者ID:Glamdring,項目名稱:welshare,代碼行數:28,代碼來源:LinkedInService.java

示例12: getFriends

import com.google.code.linkedinapi.client.LinkedInApiClient; //導入依賴的package包/類
@Override
@SqlReadonlyTransactional
public List<UserDetails> getFriends(User user) {
    if (!isServiceEnabled(user)) {
        return Collections.emptyList();
    }

    LinkedInApiClient client = helper.getClient(user);
    try {
        Connections connections = client.getConnectionsForCurrentUser();
        List<Person> connectionsList = connections.getPersonList();
        List<UserDetails> userDetails = new ArrayList<UserDetails>(connectionsList.size());
        for (Person friend : connectionsList) {
            User wsUser = dao.getByPropertyValue(User.class, "linkedInSettings.userId", friend.getId());
            if (wsUser != null) {
                UserDetails details = new UserDetails(wsUser);
                userDetails.add(details);
            }
        }

        logger.debug("Fetched " + userDetails.size()
                + " friends from linkedIn that are registered on welshare");
        return userDetails;

    } catch (FacebookException e) {
        handleException("Problem getting linkedIn friends", e, user);
        return Collections.emptyList();
    }
}
 
開發者ID:Glamdring,項目名稱:welshare,代碼行數:30,代碼來源:LinkedInService.java

示例13: publishInitialMessage

import com.google.code.linkedinapi.client.LinkedInApiClient; //導入依賴的package包/類
@Override
public void publishInitialMessage(User user) {
    if (!isServiceEnabled(user)) {
        return;
    }

    LinkedInApiClient client = helper.getClient(user);
    try {
        // TODO i18nize
        client.postNetworkUpdate("I am using Welshare! http://welshare.com");
    } catch (LinkedInApiClientException e) {
        handleException("Problem sharing initial message to twitter", e, user);
    }
}
 
開發者ID:Glamdring,項目名稱:welshare,代碼行數:15,代碼來源:LinkedInService.java

示例14: follow

import com.google.code.linkedinapi.client.LinkedInApiClient; //導入依賴的package包/類
@Override
public void follow(String externalUserId, User user) {
    if (!isServiceEnabled(user)) {
        return;
    }

    LinkedInApiClient client = helper.getClient(user);

    try {
        Person person = client.getProfileById(externalUserId);
        client.sendInviteToPerson(person, null, null);
    } catch (LinkedInApiClientException ex) {
        handleException("Problem sending linkedIn invitation", ex, user);
    }
}
 
開發者ID:Glamdring,項目名稱:welshare,代碼行數:16,代碼來源:LinkedInService.java

示例15: reshare

import com.google.code.linkedinapi.client.LinkedInApiClient; //導入依賴的package包/類
@Override
public void reshare(String messageId, String comment, User user) {
    if (!isServiceEnabled(user)) {
        return;
    }
    LinkedInApiClient client = helper.getClient(user);
    String linkedInId = getLinkedInId(messageId);
    try {
        client.reShare(linkedInId, comment, VisibilityType.ANYONE);
    } catch (LinkedInApiClientException ex) {
        handleException("Problem liking a LinkedIn update", ex, user);
    }

}
 
開發者ID:Glamdring,項目名稱:welshare,代碼行數:15,代碼來源:LinkedInService.java


注:本文中的com.google.code.linkedinapi.client.LinkedInApiClient類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。