Package com.mime.qweibo

Examples of com.mime.qweibo.QWeiboSyncApi


        }

        final JSONObject preference = preferenceUtils.getPreference();
        final String blogHost = preference.optString(Preference.BLOG_HOST);

        final QWeiboSyncApi api = new QWeiboSyncApi();
        final String callbackURL =
                "http://" + blogHost + "/tencent-microblog-oauth-callback.do";
        final String resp = api.getRequestToken(appKey, appSecret,
                                                callbackURL);

        LOGGER.log(Level.FINER, "Response[{0}]", resp);

        final OauthKey oauthKey = parseToken(resp);
View Full Code Here


        }

        final String tokenKey = request.getParameter("oauth_token");
        final String verifier = request.getParameter("oauth_verifier");

        final QWeiboSyncApi api = new QWeiboSyncApi();
        final String resp =
                api.getAccessToken(appKey, appSecret,
                                   tokenKey, tokenSecret,
                                   verifier);
        final OauthKey oauthKey = AuthorizeToken.parseToken(resp);

         final Transaction transaction =
                PreferenceGAERepository.getInstance().beginTransaction();
        try {
            preference.put(Preference.TENCENT_MICROBLOG_APP_KEY, appKey);
            preference.put(Preference.TENCENT_MICROBLOG_APP_SECRET, appSecret);
            preference.put(Preference.TENCENT_MICROBLOG_TOKEN_KEY,
                           oauthKey.tokenKey);
            preference.put(Preference.TENCENT_MICROBLOG_TOKEN_SECRET,
                           oauthKey.tokenSecret);

            preferenceUtils.setPreference(preference);
            transaction.commit();
        } catch (final Exception e) {
            if (transaction.isActive()) {
                transaction.rollback();
            }
            LOGGER.log(Level.SEVERE, e.getMessage(), e);

            return;
        }

        final String homeMsg = api.getHomeMsg(appKey, appSecret,
                                              oauthKey.tokenKey,
                                              oauthKey.tokenSecret,
                                              ResultType.ResultType_Json,
                                              PageFlag.PageFlag_First, 20);
        LOGGER.finer(homeMsg);
View Full Code Here

                                TencentMicroblogSender.class.getName()});
        try {
            final JSONObject article =
                    data.getJSONObject(Article.ARTICLE);

            final QWeiboSyncApi api = new QWeiboSyncApi();
            final String appKey = preference.getString(
                    Preference.TENCENT_MICROBLOG_APP_KEY);
            final String appSecret = preference.getString(
                    Preference.TENCENT_MICROBLOG_APP_SECRET);
            final String tokenKey = preference.getString(
                    Preference.TENCENT_MICROBLOG_TOKEN_KEY);
            final String tokenSecret = preference.getString(
                    Preference.TENCENT_MICROBLOG_TOKEN_SECRET);

            final String articleTitle = article.getString(Article.ARTICLE_TITLE);
            final String blogTitle = preference.getString(Preference.BLOG_TITLE);
            final String blogHost = preference.getString(Preference.BLOG_HOST);
            final String articlePermalink =
                    "http://" + blogHost + article.getString(
                    Article.ARTICLE_PERMALINK);

            final StringBuilder contentBuilder = new StringBuilder(articleTitle);
            contentBuilder.append(" - ").append(blogTitle).append(" ").append(
                    articlePermalink);

            api.publishMsg(appKey, appSecret, tokenKey, tokenSecret,
                           contentBuilder.toString(),
                           null, ResultType.ResultType_Json);
        } catch (final Exception e) {
            LOGGER.log(Level.SEVERE,
                       "Sends article to Tencent microblog error: {0}",
View Full Code Here

TOP

Related Classes of com.mime.qweibo.QWeiboSyncApi

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.