API 1.1 Using Cursors with Followers Ids


#1

Well this is my problem, i can get this code working without using a cursor thus it obmits the standard -1 for page one but as soon as i try to add in the cursor var in to the mix and then i get 401 any guidance would help a lot.

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 resource_url = "https://api.twitter.com/1.1/followers/ids.json"

    Dim screen_name = "SimplyBenGenius"
    Dim count = "5000"
    Dim cursor = "1432412246068745051"
    ' 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

this is what i’m passing i’ve omitted the keys out
GET&https%3A%2F%2Fapi.twitter.com%2F1.1%2Ffollowers%2Fids.json&count%3D5000%26cursor%3D1432412246068745051%26oauth_consumer_key% %26oauth_nonce% %26oauth_signature_method%3DHMAC-SHA1%26oauth_timestamp%3D1371805494%26oauth_token% %26oauth_version%3D1.0%26screen_name%3DSimplyBenGenius


#2

hesabıma erişilmiyor