2016-11-14 64 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