Chilkat Examples

ChilkatHOMEAndroid™Classic ASPCC++C#Mono C#.NET Core C#C# UWP/WinRTDataFlexDelphi ActiveXDelphi DLLVisual FoxProJavaLianjaMFCObjective-CPerlPHP ActiveXPHP ExtensionPowerBuilderPowerShellPureBasicCkPythonChilkat2-PythonRubySQL ServerSwift 2Swift 3/4TclUnicode CUnicode C++Visual Basic 6.0VB.NETVB.NET UWP/WinRTVBScriptXojo PluginNode.jsExcelGo

Visual Basic 6.0 Examples

ASN.1
Amazon S3
Amazon S3 (new)
Amazon SES
Amazon SNS
Amazon SQS
Async
Azure Cloud Storage
Azure Service Bus
Base64
Bounced Email
Box
CSR
CSV
Certificates
Compression
DKIM / DomainKey
DSA
Diffie-Hellman
Digital Signatures
Dropbox
Dynamics CRM
ECC
Email Object
Encryption
FTP
Facebook
FileAccess
Firebase
GMail REST API
GeoOp
Google APIs
Google Calendar
Google Cloud Storage
Google Drive
Google Sheets
Gzip
HTML-to-XML/Text
HTTP
HTTP Misc
IMAP
JSON
JSON Web Encryption (JWE)
JSON Web Signatures (JWS)
JSON Web Token (JWT)

Java KeyStore (JKS)
Jira
MHT / HTML Email
MIME
Microsoft Graph
NTLM
OAuth1
OAuth2
OneDrive
OpenSSL
Outlook
PEM
PFX/P12
POP3
PRNG
PayPal
Peoplevox
QuickBooks
REST
REST Misc
RSA Encryption
SCP
SFTP
SMTP
SSH
SSH Key
SSH Tunnel
SharePoint
Shopify
Socket/SSL/TLS
Spider
Stream
Stripe
SugarCRM
Tar Archive
Twitter
Upload
VoiceBase
Walmart
WebSocket
XAdES
XML
XML Digital Signatures
XMP
Xero
Zip
curl
eBay

 

 

 

(Visual Basic 6.0) Twitter - Get Follower IDs

Demonstrates how to get a list of follower IDs for a Twitter user. If the number of followers is more than can be returned in a single response, this example will use cursors to page through the followers.

Note: Rate limits will prevent a program from paging through huge lists of followers. In general, a maximum of 16 GET requests (pages) can be retrieved in a short period of time.

Chilkat ActiveX Downloads

ActiveX for 32-bit and 64-bit Windows

'  This example requires the Chilkat API to have been previously unlocked.
'  See Global Unlock Sample for sample code.

'  ----------------------------------------------------------------------
'  This initial setup, which involves setting the OAuth1 properties and connecting
'  to api.twitter.com, is only required once at the beginning.  Once connected, the same
'  object instance may be re-used, and if necessary, it will automatically reconnect
'  as needed.

'  Assume we've previously obtained an access token and saved it to a JSON file..
Dim json As New ChilkatJsonObject
Dim success As Long
success = json.LoadFile("qa_data/tokens/twitter.json")

Dim rest As New ChilkatRest
Dim oauth1 As New ChilkatOAuth1

oauth1.ConsumerKey = "TWITTER_CONSUMER_KEY"
oauth1.ConsumerSecret = "TWITTER_CONSUMER_SECRET"
oauth1.Token = json.StringOf("oauth_token")
oauth1.TokenSecret = json.StringOf("oauth_token_secret")
oauth1.SignatureMethod = "HMAC-SHA1"
success = oauth1.GenNonce(16)

success = rest.SetAuthOAuth1(oauth1,0)

Dim bAutoReconnect As Long
bAutoReconnect = 1
success = rest.Connect("api.twitter.com",443,1,bAutoReconnect)
If (success <> 1) Then
    Debug.Print rest.LastErrorText
    Exit Sub
End If

'  This ends the initial setup...
'  ----------------------------------------------------------------------

'  This Twitter user has about 77.5K followers..
success = rest.AddQueryParam("screen_name","MarcusMiller959")

Dim jsonResponse As New ChilkatJsonObject
jsonResponse.EmitCompact = 0

'  Get the 1st page of results using a cursor of "-1".
Dim sbNextCursor As New ChilkatStringBuilder
success = sbNextCursor.SetString("-1")

Dim pageNum As Long
pageNum = 1
Dim caseSensitive As Long
caseSensitive = 0
Dim bContinue As Long
bContinue = 1
'  Get a maximum of 5 pages (of 5000 ids each).
Do While bContinue = 1

    If (sbNextCursor.ContentsEqual("0",caseSensitive) = 1) Then
        '  This will cause the loop to exit..
        bContinue = 0
    Else
        '  Adds or replaces the query param.
        success = rest.AddQueryParam("cursor",sbNextCursor.GetAsString())

        '  Get the next page of follower IDs
        Dim response As String
        response = rest.FullRequestNoBody("GET","/1.1/followers/ids.json")
        If (rest.LastMethodSuccess <> 1) Then
            Debug.Print rest.LastErrorText
            Exit Sub
        End If

        success = jsonResponse.Load(response)

        If (rest.ResponseStatusCode <> 200) Then
            Debug.Print jsonResponse.Emit()
            Exit Sub
        End If

        '  Show the number of IDs returned in this
        Dim numIds As Long
        numIds = jsonResponse.SizeOfArray("ids")
        Debug.Print "Page " & pageNum & ", Number of Ids: " & numIds

        '  Show the 1st 10 ids in this page.
        Dim i As Long
        i = 0
        Do While i < numIds
            jsonResponse.I = i
            Debug.Print "    " & i & ": " & jsonResponse.StringOf("ids[i]")

            i = i + 1
            If (i > 10) Then
                '  Force the loop to exit.
                i = numIds
            End If

        Loop

        pageNum = pageNum + 1
        If (pageNum > 5) Then
            bContinue = 0
        Else
            success = sbNextCursor.SetString(jsonResponse.StringOf("next_cursor_str"))
        End If

    End If

Loop

'  A successful JSON response for the 1st page looks like this:

'  	{
' 	  "ids": [
'  	    3140496044,
'  	    793204773751324672,
'  	    789951187781050369,
'  	    763520773587922945,
'  	    ...
'  	    15031286,
'  	    2668251246,
'  	    3751659443
'  	  ],
'  	  "next_cursor": 1531680438812851153,
'  	  "next_cursor_str": "1531680438812851153",
'  	  "previous_cursor": 0,
'  	  "previous_cursor_str": "0"
'  	}

'  The output of this program looks like this:

'  	Page 1, Number of Ids: 5000
'  	    0: 931953350
'  	    1: 786708055
'  	    2: 560845700
'  	    3: 3140496044
'  	    4: 793204773751324672
'  	    5: 789951187781050369
'  	    6: 763520773587922945
'  	    7: 793143274059988992
'  	    8: 793139683412762624
'  	    9: 1588222783
'  	    10: 703821370778451968
'  	Page 2, Number of Ids: 5000
'  	    0: 15031286
'  	    1: 2668251246
'  	    2: 3751659443
'  	    3: 3324584493
'  	    4: 2440214809
'  	    5: 1322335441
'  	    6: 4439178393
'  	    7: 4911573711
'  	    8: 720792880080560128
'  	    9: 720805087124267008
'  	    10: 172926330
'  	Page 3, Number of Ids: 5000
'  	    0: 93867176
'  	    1: 2992946183
'  	    2: 2825296077
'  	    3: 3784572861
'  	    4: 2150051321
'  	    5: 2460881603
'  	    6: 4128849341
'  	    7: 2234697931
'  	    8: 2379418164
'  	    9: 3425171542
'  	    10: 325759186
'  	Page 4, Number of Ids: 5000
'  	    0: 22793412
'  	    1: 3347750489
'  	    2: 316923043
'  	    3: 2481719196
'  	    4: 3363591905
'  	    5: 3238116492
'  	    6: 58467130
'  	    7: 3015182362
'  	    8: 2985342719
'  	    9: 3095965720
'  	    10: 17505957
'  	Page 5, Number of Ids: 5000
'  	    0: 2541434684
'  	    1: 140022957
'  	    2: 134845054
'  	    3: 772810508
'  	    4: 16979294
'  	    5: 2320540225
'  	    6: 105439442
'  	    7: 2796744529
'  	    8: 251128801
'  	    9: 350229758
'  	    10: 2683994716
' 

 

© 2000-2016 Chilkat Software, Inc. All Rights Reserved.