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

DataFlex 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

 

 

 

(DataFlex) Get the Photos for a User

Demonstrates how to get the photos that the user has uploaded.

Chilkat ActiveX Downloads

ActiveX for 32-bit and 64-bit Windows

Use ChilkatAx-win32.pkg

Procedure Test
    Variant vOauth2
    Handle hoOauth2
    Handle hoRest
    Boolean iSuccess
    String sResponseJson
    Handle hoJson
    Handle hoDtime
    Boolean iBLocalTime
    Variant vDt
    Handle hoDt
    Integer i
    Integer iNumItems
    String sName
    String sTemp1
    Integer iTemp1
    Integer iTemp2
    Integer iTemp3
    Integer iTemp4
    Integer iTemp5
    Boolean bTemp1

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

    // This example assumes a previously obtained an access token
    Get Create (RefClass(cComChilkatOAuth2)) To hoOauth2
    If (Not(IsComObjectCreated(hoOauth2))) Begin
        Send CreateComObject of hoOauth2
    End
    Set ComAccessToken Of hoOauth2 To "FACEBOOK-ACCESS-TOKEN"

    Get Create (RefClass(cComChilkatRest)) To hoRest
    If (Not(IsComObjectCreated(hoRest))) Begin
        Send CreateComObject of hoRest
    End

    // Connect to Facebook.
    Get ComConnect Of hoRest "graph.facebook.com" 443 True True To iSuccess
    If (iSuccess <> True) Begin
        Get ComLastErrorText Of hoRest To sTemp1
        Showln sTemp1
        Procedure_Return
    End

    // Provide the authentication credentials (i.e. the access key)
    Get pvComObject of hoOauth2 to vOauth2
    Get ComSetAuthOAuth2 Of hoRest vOauth2 To iSuccess

    // Indicate that we only want the photos the user has personally uploaded.
    Get ComAddQueryParam Of hoRest "type" "uploaded" To iSuccess

    // We could limit the number of photos by setting a limit.
    Get ComAddQueryParam Of hoRest "limit" "5" To iSuccess

    // Gets the 1st page of photos. (Not the actual image data, but the information about each photo.)
    // See https://developers.facebook.com/docs/graph-api/reference/user/photos/ for more information.
    Get ComFullRequestNoBody Of hoRest "GET" "/v2.7/me/photos" To sResponseJson
    Get ComLastMethodSuccess Of hoRest To bTemp1
    If (bTemp1 <> True) Begin
        Get ComLastErrorText Of hoRest To sTemp1
        Showln sTemp1
        Procedure_Return
    End

    Get Create (RefClass(cComChilkatJsonObject)) To hoJson
    If (Not(IsComObjectCreated(hoJson))) Begin
        Send CreateComObject of hoJson
    End
    Set ComEmitCompact Of hoJson To False
    Get ComLoad Of hoJson sResponseJson To iSuccess
    Get ComEmit Of hoJson To sTemp1
    Showln sTemp1

    // A sample JSON response is shown below.  
    // This is the code to parse the JSON response.

    Get Create (RefClass(cComCkDateTime)) To hoDtime
    If (Not(IsComObjectCreated(hoDtime))) Begin
        Send CreateComObject of hoDtime
    End
    Move True To iBLocalTime

    Move 0 To i
    Get ComSizeOfArray Of hoJson "data" To iNumItems
    While (i < iNumItems)
        Set ComI Of hoJson To i
        Showln "--- " i
        Get ComStringOf Of hoJson "data[i].name" To sName
        Get ComLastMethodSuccess Of hoJson To bTemp1
        If (bTemp1 = True) Begin
            Showln "name: " sName
        End

        Get ComStringOf Of hoJson "data[i].id" To sTemp1
        Showln "id: " sTemp1

        // We can load the created_time into a CkDateTime...
        Get ComStringOf Of hoJson "data[i].created_time" To sTemp1
        Get ComSetFromTimestamp Of hoDtime sTemp1 To iSuccess
        Get ComGetDtObj Of hoDtime iBLocalTime To vDt
        If (IsComObject(vDt)) Begin
            Get Create (RefClass(cComChilkatDtObj)) To hoDt
            Set pvComObject Of hoDt To vDt
        End
        Get ComMonth Of hoDt To iTemp1
        Get ComDay Of hoDt To iTemp2
        Get ComYear Of hoDt To iTemp3
        Get ComHour Of hoDt To iTemp4
        Get ComMinute Of hoDt To iTemp5
        Showln iTemp1 "/" iTemp2 "/" iTemp3 "  " iTemp4 ":" iTemp5
        Send Destroy of hoDt
        Move (i + 1) To i
    Loop

    // We can get the paging information as follows:
    Get ComStringOf Of hoJson "paging.next" To sTemp1
    Showln "URL for next page: " sTemp1
    Get ComStringOf Of hoJson "paging.cursors.before" To sTemp1
    Showln "before cursor: " sTemp1
    Get ComStringOf Of hoJson "paging.cursors.after" To sTemp1
    Showln "after cursor: " sTemp1

    // This is a sample JSON response:
    // { 
    //   "data": [
    //     {
    //       "created_time": "2016-09-29T20:46:18+0000",
    //       "name": "Ignore my posts -- I'm doing some testing for Facebook related programming...",
    //       "id": "10210199026347451"
    //     },
    //     { 
    //       "created_time": "2016-09-19T02:00:42+0000",
    //       "id": "10210091531240138"
    //     },
    //     { 
    //       "created_time": "2016-09-19T02:00:42+0000",
    //       "id": "10210091520620125"
    //     },
    //     { 
    //       "created_time": "2016-09-19T01:59:46+0000",
    //       "name": "I would've went for a swim had it not been for the sign",
    //       "id": "10210091522299917"
    //     },
    //     { 
    //       "created_time": "2016-09-12T00:37:35+0000",
    //       "id": "10210023316834798"
    //     }
    //   ],
    //   "paging": { 
    //     "cursors": { 
    //       "before": "MTAyMTAxOTkwMjYzNDc0NTEZD",
    //       "after": "MTAyMTAwMjMzMTU4MzQ3OTgZD"
    //     },
    //     "next": "https:\/\/graph.facebook.com\/v2.7\/10224048320139890\/photos?type=uploaded&limit=5&after=MTAyMTAwMjMzMTU4MzQ3OTgZD"
    //   }
    // }
    // 


End_Procedure

 

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