Package com.google.api.services.plus.model

Examples of com.google.api.services.plus.model.ActivityFeed


        .build();

        Plus.Activities.List listActivities = plus.activities().list("me", "public").setFields(Constants.TARGET_ACTIVITY_FIELDS);

        // 最初のページのリクエストを実行します
        ActivityFeed activityFeed = listActivities.execute();

        // リクエストのラップを解除し、必要な部分を抽出します
        List<Activity> activities = activityFeed.getItems();

        while (activities != null) {

            for (Activity activity : activities) {

                ActivityModel oldModel = ActivityService.getActivity(activity.getId());

                try {
                    if(oldModel == null) {
                        ActivityService.putActivity(activity, userModel);
                    }

                }catch (DataInvalidException e) {};
            }

            // 次のページのトークンが null になると、最終ページに到達したことがわかります。
            // その場合は break。
            if (activityFeed.getNextPageToken() == null) {
                break;
            }

            // 次のページのアクティビティをリクエストする準備をします
            listActivities.setPageToken(activityFeed.getNextPageToken());

            // 次のページのリクエストを実行して処理します
            activityFeed = listActivities.execute();
            activities = activityFeed.getItems();
        }

    }
View Full Code Here



        Plus.Activities.List listActivities = plus.activities().list("me", "public").setFields(Constants.TARGET_ACTIVITY_FIELDS);

        // 最初のページのリクエストを実行します
        ActivityFeed activityFeed = listActivities.execute();

        // リクエストのラップを解除し、必要な部分を抽出します
        List<Activity> activities = activityFeed.getItems();

        // Twitter対象リスト
        List<String> activityIdList = new ArrayList<String>();
        // Facebook対象リスト
        List<String> facebookActivityIdList = new ArrayList<String>();
View Full Code Here

        Plus plus = new Plus(TRANSPORT, JSON_FACTORY, credential);
        Plus.Activities.List listActivities = plus.activities().list("me", "public").setFields(Constants.TARGET_ACTIVITY_FIELDS);

        // 最初のページのリクエストを実行します
        ActivityFeed activityFeed = listActivities.execute();

        // リクエストのラップを解除し、必要な部分を抽出します
        List<Activity> activities = activityFeed.getItems();

        // 返却用リスト
        List<ActivityModel> activityModelList = new ArrayList<ActivityModel>();


        try {
            while (activities != null) {
                for (Activity activity : activities) {


                    Date baseDate = new Date();

                    Calendar calendar = Calendar.getInstance();
                    calendar.setTimeInMillis(activity.getPublished().getValue());
                    calendar.add(Calendar.HOUR, 9);

                    Date published = calendar.getTime();

//                    if(activity.getId().equals("z13nyfjxioabg33uo22qyvnrbr3tghqac04")) {
//                        System.out.println("baseDate:" + baseDate + "|" + "published:" + published + "|" + activity.getPublished().toStringRfc3339());
//                        System.out.println(Utils.differenceDays(baseDate, published));
//                    }

                    // 今日のアクティビティのみを取込む
                    if(Utils.differenceDays(baseDate, published) != 0) {
                        throw new DataInvalidException();
                    }

                    try {

                        ActivityModel oldModel = ActivityService.getActivity(activity.getId());

                        // 新規アクティビティ もしくは 更新されている場合
                        if(oldModel == null || oldModel.getUpdated().before(new Date(activity.getUpdated().getValue()))) {
                            ActivityModel activityModel = ActivityService.putActivity(activity, userModel);
                            activityModelList.add(activityModel);
                        }

                    }catch (Exception e) {};
                }

                // 次のページのトークンが null になると、最終ページに到達したことがわかります。
                // その場合は break。
                if (activityFeed.getNextPageToken() == null) {
                    break;
                }

                // 次のページのアクティビティをリクエストする準備をします
                listActivities.setPageToken(activityFeed.getNextPageToken());

                // 次のページのリクエストを実行して処理します
                activityFeed = listActivities.execute();
                activities = activityFeed.getItems();
            }
        }catch (DataInvalidException e) {};

        requestScope("activityList", activityModelList);
        requestScope("userModel", userModel);
View Full Code Here

        Plus plus = new Plus(TRANSPORT, JSON_FACTORY, credential);
        Plus.Activities.List listActivities = plus.activities().list("me", "public").setFields(Constants.TARGET_ACTIVITY_FIELDS);

        // 最初のページのリクエストを実行します
        ActivityFeed activityFeed = listActivities.execute();

        // リクエストのラップを解除し、必要な部分を抽出します
        List<Activity> activities = activityFeed.getItems();

        // 返却用カウント数
        int activityCount = 0;


        try {
            while (activities != null) {
                for (Activity activity : activities) {

                        ActivityModel oldModel = ActivityService.getActivity(activity.getId());

                        // 新規アクティビティ
                        if(oldModel == null) {
                            // アクティビティを追加
                            try {
                                ActivityService.putActivity(activity, userModel);
                                // カウントの加算
                                activityCount++;

                            }catch (Exception e) {};

                        }else {
                            // 最後まで取り込みが完了しているユーザーで、
                            // 存在するアクティビティに到着した場合は処理を終了する。
                            if(userModel.isInputActivityLastFinishFlg()) {
                                throw new DataInvalidException();
                            }
                        }
                }

                // 次のページのトークンが null になると、最終ページに到達したことがわかります。
                // その場合は break。
                if (activityFeed.getNextPageToken() == null) {
                    break;
                }

                // 次のページのアクティビティをリクエストする準備をします
                listActivities.setPageToken(activityFeed.getNextPageToken());

                // 次のページのリクエストを実行して処理します
                activityFeed = listActivities.execute();
                activities = activityFeed.getItems();
            }

            // 初めて、全取り込みを行ったユーザーの全取り込み完了フラグを更新
            if(!userModel.isInputActivityLastFinishFlg()) {
                userModel.setInputActivityLastFinishFlg(true);
View Full Code Here

        .build();

        Plus.Activities.List listActivities = plus.activities().list("me", "public").setFields(Constants.TARGET_ACTIVITY_FIELDS);

        // 最初のページのリクエストを実行します
        ActivityFeed activityFeed = listActivities.execute();

        // リクエストのラップを解除し、必要な部分を抽出します
        List<Activity> activities = activityFeed.getItems();

        // Twitter対象リスト
        List<String> twitterActivityIdList = new ArrayList<String>();
        // Facebook対象リスト
        List<String> facebookActivityIdList = new ArrayList<String>();
        // Evernote対象リスト
        List<String> evernoteActivityIdList = new ArrayList<String>();

        int count = 1;

        while (activities != null && count <= limit) {

            for (Activity activity : activities) {

                ActivityModel oldModel = ActivityService.getActivity(activity.getId());

                try {
                    if(oldModel == null) {
                        ActivityModel newActivityModel = ActivityService.putActivity(activity, userModel);

                        // アルバム内の画像を保存
                        List<Attachments> attachmentsList = activity.getObject().getAttachments();
                        if(attachmentsList != null
                                && attachmentsList.size() > 0) {

                            Attachments attachment = attachmentsList.get(0);
                            if(attachment.getThumbnails() != null && attachment.getThumbnails().size() > 0) {

                                for(Thumbnails thumbnails: attachment.getThumbnails()) {
                                    if(thumbnails != null && thumbnails.getImage() != null) {
                                        AlbumService.put(newActivityModel, thumbnails.getUrl(), thumbnails.getImage().getUrl(), thumbnails.getImage().getHeight(), thumbnails.getImage().getWidth());
                                    }
                                }
                            }
                        }

                     // 他のSNSへの転送
                        if(!Utils.isNoShare(newActivityModel)) {
                            // twitterへPOST対象リストを作成
                            if(Utils.isTwitterRepost(userModel, newActivityModel)) {
                                twitterActivityIdList.add(activity.getId());
                            }

                            // facebookへPOST対象リストを作成
                            if(Utils.isFacebookRepost(userModel, newActivityModel)) {
                                facebookActivityIdList.add(activity.getId());
                            }

                            // EvernoteへPOST対象リストを作成
                            if(Utils.isEvernoteRepost(userModel, newActivityModel)) {
                                evernoteActivityIdList.add(activity.getId());
                            }
                        }
                    }

                }catch (DataInvalidException e) {};
            }

            // 次のページのトークンが null になると、最終ページに到達したことがわかります。
            // その場合は break。
            if (activityFeed.getNextPageToken() == null) {
                break;
            }

            // 次のページのアクティビティをリクエストする準備をします
            listActivities.setPageToken(activityFeed.getNextPageToken());

            // 次のページのリクエストを実行して処理します
            activityFeed = listActivities.execute();
            activities = activityFeed.getItems();

            // API呼び出しカウントを加算
            count++;
        }
View Full Code Here

    public List<StatusActivity> fetchActivities() {
        List<StatusActivity> statuses = new ArrayList<StatusActivity>();

        DateFormat googleFormatter = new SimpleDateFormat(DATE_FORMAT, Locale.ENGLISH);
        try {
            ActivityFeed feed = api.activities().list(this.googleId, "public").execute();
            for (Activity activity : feed.getItems()) {
                String content = activity.getPlusObject().getContent();
                if ("share".equals(activity.getVerb())) {
                    content = "<br/>Message original de " + mention(activity.getPlusObject().getActor()) + " : <div class='google reshare'>" + content + "</div>";
                }
                String annotation = activity.getAnnotation();
View Full Code Here

TOP

Related Classes of com.google.api.services.plus.model.ActivityFeed

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.