【问题标题】:Twitter pagination for home_timeline API not workinghome_timeline API 的 Twitter 分页不起作用
【发布时间】:2017-03-27 22:52:50
【问题描述】:

我正在使用 twitter home_timeline API 来显示推文。
我第一次运行它时工作正常,但是当我再次调用它时(拉动以加载更多),它没有响应。我正在传递身份验证标头,并且在参数中我传递了计数,它也不起作用。
我不知道我卡在哪里了。。
这是拉推文的代码:

if (auth != null && auth.token_type.equals("bearer")) {

    HttpGet httpget = new HttpGet(TwitterStreamURL);

    String oAuthConsumerKey = CONSUMER_KEY;
    String oAuthConsumerSecret = CONSUMER_SECRET;

    String oAuthAccessToken = HomeActivity.twitter_access_token;
    String oAuthAccessTokenSecret = HomeActivity.twitter_access_token_secret;

    String oAuthNonce = String.valueOf(System.currentTimeMillis());
    String oAuthSignatureMethod = "HMAC-SHA1";
    String oAuthTimestamp = time();
    String oAuthVersion = "1.0";
    String signatureBaseString1 = methods;
    String signatureBaseString2 = TwitterStreamURL;
    String signatureBaseString3Templ = "oauth_consumer_key=%s&oauth_nonce=%s&oauth_signature_method=%s&oauth_timestamp=%s&oauth_token=%s&oauth_version=%s";
    String signatureBaseString3 = String.format(signatureBaseString3Templ,
            oAuthConsumerKey,
            oAuthNonce,
            oAuthSignatureMethod,
            oAuthTimestamp,
            oAuthAccessToken,
            oAuthVersion);

    String signatureBaseStringTemplate = "%s&%s&%s";
    try {
        signatureBaseString = String.format(signatureBaseStringTemplate,
                URLEncoder.encode(signatureBaseString1, "UTF-8"),
                URLEncoder.encode(signatureBaseString2, "UTF-8"),
                URLEncoder.encode(signatureBaseString3, "UTF-8"));
    } catch (UnsupportedEncodingException e) {
        e.printStackTrace();
    }

    try {
        compositeKey = URLEncoder.encode(oAuthConsumerSecret, "UTF-8") + "&" + URLEncoder.encode(oAuthAccessTokenSecret, "UTF-8");
    } catch (UnsupportedEncodingException e) {
        e.printStackTrace();
    }

    try {
        String oAuthSignature = computeSignature(signatureBaseString, compositeKey);

        oAuthSignatureEncoded = URLEncoder.encode(oAuthSignature, "UTF-8");

        String authorizationHeaderValueTempl = "OAuth oauth_consumer_key=\"%s\", oauth_nonce=\"%s\", oauth_signature=\"%s\", oauth_signature_method=\"%s\", oauth_timestamp=\"%s\", oauth_token=\"%s\", oauth_version=\"%s\"";

        String authorizationHeaderValue = String.format(authorizationHeaderValueTempl,
                oAuthConsumerKey,
                oAuthNonce,
                oAuthSignatureEncoded,
                oAuthSignatureMethod,
                oAuthTimestamp,
                oAuthAccessToken,
                oAuthVersion);
    } catch (Exception e) {
        e.printStackTrace();
    }


    String vf = "oauth_consumer_key=" + oAuthConsumerKey + ",oauth_signature_method=" + oAuthSignatureMethod + ",oauth_timestamp=" + oAuthTimestamp + ",oauth_nonce=" + oAuthNonce + ",oauth_version=" + oAuthVersion + ",oauth_token=" + oAuthAccessToken + ",oauth_signature=" + oAuthSignatureEncoded + "";
    httpget.setHeader("Authorization", "OAuth " + "oauth_consumer_key=" + oAuthConsumerKey + ",oauth_signature_method=" + oAuthSignatureMethod + ",oauth_timestamp=" + oAuthTimestamp + ",oauth_nonce=" + oAuthNonce + ",oauth_version=" + oAuthVersion + ",oauth_token=" + oAuthAccessToken + ",oauth_signature=" + oAuthSignatureEncoded + "");
        httpget.setHeader("Content-Type", "application/json");

    // update the results with the body of the response
    checkTwitRes = true;
    results = getResponseBody(httpget);
}

【问题讨论】:

    标签: java android twitter twitter-oauth twitter-timeline


    【解决方案1】:
    div {
        color:#000;
        font-weight:800
    }
    
    p {
        color:red;
        background:url("mypicture.png")
    }
    

    【讨论】:

    • java / android 问题的无关 css 答案
    猜你喜欢
    • 1970-01-01
    • 2014-07-26
    • 1970-01-01
    • 2016-02-12
    • 1970-01-01
    • 2015-09-03
    • 2011-02-12
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多