2016-11-14 63 views
3

我正在使用twitter home_timeline API显示推文。
我第一次运行它可以正常工作,但是当我再次调用它时(拉加载更多),它不响应。我传递auth头文件,并在我传递的参数中计数,它不起作用。
我不知道我在哪里卡住..
这里是拉鸣叫代码:home_timeline API不工作的Twitter分页

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); 
} 

回答

-1
div { 
    color:#000; 
    font-weight:800 
} 

p { 
    color:red; 
    background:url("mypicture.png") 
} 
+0

无关CSS的答案给java/Android的问题 – Rohit