我的所有代码都存在问题,无法在没有 Cursors var 的情况下获得前 5000 个 id,但是一旦我将其添加到整个代码中,它就会停止工作,并且这里的工作代码根本不返回任何东西..
Dim oauth_token = ""
Dim oauth_token_secret = ""
Dim oauth_consumer_key = ""
Dim oauth_consumer_secret = ""
' oauth implementation details
Dim oauth_version = "1.0"
Dim oauth_signature_method = "HMAC-SHA1"
' unique request details
Dim oauth_nonce = Convert.ToBase64String(New ASCIIEncoding().GetBytes(DateTime.Now.Ticks.ToString()))
Dim timeSpan = DateTime.UtcNow - New DateTime(1970, 1, 1, 0, 0, 0, _
0, DateTimeKind.Utc)
Dim oauth_timestamp = Convert.ToInt64(timeSpan.TotalSeconds).ToString()
' message api details
Dim status = "Updating status via REST API if this works"
Dim resource_url = "https://api.twitter.com/1.1/followers/ids.json"
Dim screen_name = "SimplyBenGenius"
Dim count = "5000"
Dim cursor = "-1"
' create oauth signature
Dim baseFormat = "count={7}&oauth_consumer_key={0}&oauth_nonce={1}&oauth_signature_method={2}" + "&oauth_timestamp={3}&oauth_token={4}&oauth_version={5}&screen_name={6}"
Dim baseString = String.Format(baseFormat, oauth_consumer_key, oauth_nonce, oauth_signature_method, oauth_timestamp, oauth_token, _
oauth_version, Uri.EscapeDataString(screen_name), Uri.EscapeDataString(count), Uri.EscapeDataString(cursor))
baseString = String.Concat("GET&", Uri.EscapeDataString(resource_url), "&", Uri.EscapeDataString(baseString))
Dim compositeKey = String.Concat(Uri.EscapeDataString(oauth_consumer_secret), "&", Uri.EscapeDataString(oauth_token_secret))
Dim oauth_signature As String
Using hasher As New HMACSHA1(ASCIIEncoding.ASCII.GetBytes(compositeKey))
oauth_signature = Convert.ToBase64String(hasher.ComputeHash(ASCIIEncoding.ASCII.GetBytes(baseString)))
End Using
' create the request header
Dim headerFormat = "OAuth oauth_nonce=""{0}"", oauth_signature_method=""{1}"", " + "oauth_timestamp=""{2}"", oauth_consumer_key=""{3}"", " + "oauth_token=""{4}"", oauth_signature=""{5}"", " + "oauth_version=""{6}"""
Dim authHeader = String.Format(headerFormat, Uri.EscapeDataString(oauth_nonce), Uri.EscapeDataString(oauth_signature_method), Uri.EscapeDataString(oauth_timestamp), Uri.EscapeDataString(oauth_consumer_key), Uri.EscapeDataString(oauth_token), _
Uri.EscapeDataString(oauth_signature), Uri.EscapeDataString(oauth_version))
' make the request
ServicePointManager.Expect100Continue = False
Dim postBody = "screen_name=" + Uri.EscapeDataString(screen_name)
'
Dim postbody2 = "count=" + Uri.EscapeDataString(count)
resource_url += "?" + postBody + "&" + postbody2
Dim request As HttpWebRequest = DirectCast(WebRequest.Create(resource_url), HttpWebRequest)
request.Headers.Add("Authorization", authHeader)
request.Method = "GET"
request.ContentType = "application/x-www-form-urlencoded"
Dim response As WebResponse = request.GetResponse()
Dim responseData As String = New StreamReader(response.GetResponseStream()).ReadToEnd()
RichTextBox1.Text = responseData
这就是我添加游标的目的,但没有运气..
Dim oauth_token = ""
Dim oauth_token_secret = ""
Dim oauth_consumer_key = ""
Dim oauth_consumer_secret = ""
' oauth implementation details
Dim oauth_version = "1.0"
Dim oauth_signature_method = "HMAC-SHA1"
' unique request details
Dim oauth_nonce = Convert.ToBase64String(New ASCIIEncoding().GetBytes(DateTime.Now.Ticks.ToString()))
Dim timeSpan = DateTime.UtcNow - New DateTime(1970, 1, 1, 0, 0, 0, _
0, DateTimeKind.Utc)
Dim oauth_timestamp = Convert.ToInt64(timeSpan.TotalSeconds).ToString()
' message api details
Dim status = "Updating status via REST API if this works"
Dim resource_url = "https://api.twitter.com/1.1/followers/ids.json"
Dim screen_name = "SimplyBenGenius"
Dim count = "5000"
Dim cursor = "-1"
' create oauth signature
Dim baseFormat = "count={7}&cursor={8}&oauth_consumer_key={0}&oauth_nonce={1}&oauth_signature_method={2}" + "&oauth_timestamp={3}&oauth_token={4}&oauth_version={5}&screen_name={6}" ''
Dim baseString = String.Format(baseFormat, oauth_consumer_key, oauth_nonce, oauth_signature_method, oauth_timestamp, oauth_token, _
oauth_version, Uri.EscapeDataString(screen_name), Uri.EscapeDataString(count), Uri.EscapeDataString(cursor))
baseString = String.Concat("GET&", Uri.EscapeDataString(resource_url), "&", Uri.EscapeDataString(baseString))
Dim compositeKey = String.Concat(Uri.EscapeDataString(oauth_consumer_secret), "&", Uri.EscapeDataString(oauth_token_secret))
Dim oauth_signature As String
Using hasher As New HMACSHA1(ASCIIEncoding.ASCII.GetBytes(compositeKey))
oauth_signature = Convert.ToBase64String(hasher.ComputeHash(ASCIIEncoding.ASCII.GetBytes(baseString)))
End Using
' create the request header
Dim headerFormat = "OAuth oauth_nonce=""{0}"", oauth_signature_method=""{1}"", " + "oauth_timestamp=""{2}"", oauth_consumer_key=""{3}"", " + "oauth_token=""{4}"", oauth_signature=""{5}"", " + "oauth_version=""{6}"""
Dim authHeader = String.Format(headerFormat, Uri.EscapeDataString(oauth_nonce), Uri.EscapeDataString(oauth_signature_method), Uri.EscapeDataString(oauth_timestamp), Uri.EscapeDataString(oauth_consumer_key), Uri.EscapeDataString(oauth_token), _
Uri.EscapeDataString(oauth_signature), Uri.EscapeDataString(oauth_version))
' make the request
ServicePointManager.Expect100Continue = False
Dim postBody = "screen_name=" + Uri.EscapeDataString(screen_name)
'
Dim postbody2 = "count=" + Uri.EscapeDataString(count)
resource_url += "?" + postBody + "&" + postbody2
Dim request As HttpWebRequest = DirectCast(WebRequest.Create(resource_url), HttpWebRequest)
request.Headers.Add("Authorization", authHeader)
request.Method = "GET"
request.ContentType = "application/x-www-form-urlencoded"
Dim response As WebResponse = request.GetResponse()
Dim responseData As String = New StreamReader(response.GetResponseStream()).ReadToEnd()
RichTextBox1.Text += responseData
任何建议都会很棒,这可能是一个简单的修复,但我似乎看不到它..