Chilkat Examples

ChilkatHOME.NET Core C#Android™AutoItCC#C++Chilkat2-PythonCkPythonClassic ASPDataFlexDelphi ActiveXDelphi DLLGoJavaLianjaMono C#Node.jsObjective-CPHP ActiveXPHP ExtensionPerlPowerBuilderPowerShellPureBasicRubySQL ServerSwift 2Swift 3,4,5...TclUnicode CUnicode C++VB.NETVBScriptVisual Basic 6.0Visual FoxProXojo Plugin

Visual FoxPro Web API Examples

Primary Categories

ABN AMRO
AWS Secrets Manager
AWS Security Token Service
AWS Translate
Activix CRM
Adyen
Alibaba Cloud OSS
Amazon Cognito
Amazon DynamoDB
Amazon MWS
Amazon Pay
Amazon Rekognition
Amazon SP-API
Amazon Voice ID
Aruba Fatturazione
Azure Maps
Azure Monitor
Azure OAuth2
Azure Storage Accounts
Backblaze S3
Banco Inter
Belgian eHealth Platform
Bitfinex v2 REST
Bluzone
BrickLink
Bunny CDN
CallRail
CardConnect
Cerved
ClickBank
Clickatell
Cloudfare
Constant Contact
DocuSign
Duo Auth MFA
ETrade
Ecwid
Egypt ITIDA
Egypt eReceipt
Etsy
Facebook
Faire
Frame.io
GeoOp
GetHarvest
Global Payments
Google People
Google Search Console
Google Translate
Google Vision
Hungary NAV Invoicing
IBM Text to Speech
Ibanity
IntakeQ
JCC Cyprus
Jira
Lightspeed
MYOB
Magento
Mailgun
Malaysia MyInvois

Mastercard
MedTunnel
MercadoLibre
MessageMedia
Microsoft Calendar
Microsoft Group
Microsoft Tasks and Plans
Microsoft Teams
Moody's
Okta OAuth/OIDC
OneLogin OIDC
OneNote
OpenAI ChatGPT
PRODA
PayPal
Paynow.pl
Peoplevox
Populi
QuickBooks
Rabobank
Refinitiv
Royal Mail OBA
SCiS Schools Catalogue
SII Chile
SMSAPI
SOAP finkok.com
Salesforce
SendGrid
Shippo
Shopify
Shopware
Shopware 6
SimpleTexting
Square
Stripe
SugarCRM
TicketBAI
TikTok Shop
Trello
Twilio
Twitter API v2
Twitter v1
UPS
UniPin
VoiceBase
Vonage
WaTrend
Walmart v3
Wasabi
WhatsApp
WiX
WooCommerce
WordPress
Xero
Yahoo Mail
Yapily
Yousign
ZATCA
Zendesk
Zoom
_Miscellaneous_
eBay
effectconnect
hacienda.go.cr

 

 

 

(Visual FoxPro) 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

LOCAL loJson
LOCAL lnSuccess
LOCAL loRest
LOCAL loOauth1
LOCAL lnBAutoReconnect
LOCAL loJsonResponse
LOCAL loSbNextCursor
LOCAL lnPageNum
LOCAL lnCaseSensitive
LOCAL lnBContinue
LOCAL lcResp
LOCAL lnNumIds
LOCAL i

* 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..
* For versions of Chilkat < 10.0.0, use CreateObject('Chilkat_9_5_0.JsonObject')
loJson = CreateObject('Chilkat.JsonObject')
lnSuccess = loJson.LoadFile("qa_data/tokens/twitter.json")

* For versions of Chilkat < 10.0.0, use CreateObject('Chilkat_9_5_0.Rest')
loRest = CreateObject('Chilkat.Rest')
* For versions of Chilkat < 10.0.0, use CreateObject('Chilkat_9_5_0.OAuth1')
loOauth1 = CreateObject('Chilkat.OAuth1')

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

loRest.SetAuthOAuth1(loOauth1,0)

lnBAutoReconnect = 1
lnSuccess = loRest.Connect("api.twitter.com",443,1,lnBAutoReconnect)
IF (lnSuccess <> 1) THEN
    ? loRest.LastErrorText
    RELEASE loJson
    RELEASE loRest
    RELEASE loOauth1
    CANCEL
ENDIF

* This ends the initial setup...
* ----------------------------------------------------------------------

* This Twitter user has about 77.5K followers..
loRest.AddQueryParam("screen_name","MarcusMiller959")

* For versions of Chilkat < 10.0.0, use CreateObject('Chilkat_9_5_0.JsonObject')
loJsonResponse = CreateObject('Chilkat.JsonObject')
loJsonResponse.EmitCompact = 0

* Get the 1st page of results using a cursor of "-1".
* For versions of Chilkat < 10.0.0, use CreateObject('Chilkat_9_5_0.StringBuilder')
loSbNextCursor = CreateObject('Chilkat.StringBuilder')
loSbNextCursor.SetString("-1")

lnPageNum = 1
lnCaseSensitive = 0
lnBContinue = 1
* Get a maximum of 5 pages (of 5000 ids each).
DO WHILE lnBContinue = 1

    IF (loSbNextCursor.ContentsEqual("0",lnCaseSensitive) = 1) THEN
        * This will cause the loop to exit..
        lnBContinue = 0
    ELSE
        * Adds or replaces the query param.
        loRest.AddQueryParam("cursor",loSbNextCursor.GetAsString())

        * Get the next page of follower IDs
        lcResp = loRest.FullRequestNoBody("GET","/1.1/followers/ids.json")
        IF (loRest.LastMethodSuccess <> 1) THEN
            ? loRest.LastErrorText
            RELEASE loJson
            RELEASE loRest
            RELEASE loOauth1
            RELEASE loJsonResponse
            RELEASE loSbNextCursor
            CANCEL
        ENDIF

        loJsonResponse.Load(lcResp)

        IF (loRest.ResponseStatusCode <> 200) THEN
            ? loJsonResponse.Emit()
            RELEASE loJson
            RELEASE loRest
            RELEASE loOauth1
            RELEASE loJsonResponse
            RELEASE loSbNextCursor
            CANCEL
        ENDIF

        * Show the number of IDs returned in this 
        lnNumIds = loJsonResponse.SizeOfArray("ids")
        ? "Page " + STR(lnPageNum) + ", Number of Ids: " + STR(lnNumIds)

        * Show the 1st 10 ids in this page.
        i = 0
        DO WHILE i < lnNumIds
            loJsonResponse.I = i
            ? "    " + STR(i) + ": " + loJsonResponse.StringOf("ids[i]")

            i = i + 1
            IF (i > 10) THEN
                * Force the loop to exit.
                i = lnNumIds
            ENDIF

        ENDDO

        lnPageNum = lnPageNum + 1
        IF (lnPageNum > 5) THEN
            lnBContinue = 0
        ELSE
            loSbNextCursor.SetString(loJsonResponse.StringOf("next_cursor_str"))
        ENDIF

    ENDIF

ENDDO

* 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
* 

RELEASE loJson
RELEASE loRest
RELEASE loOauth1
RELEASE loJsonResponse
RELEASE loSbNextCursor


 

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