Chilkat Examples

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

DataFlex Web API Examples

Primary Categories

ABN AMRO
AWS Secrets Manager
AWS Translate
Activix CRM
Adyen
Alibaba Cloud OSS
Amazon Cognito
Amazon DynamoDB
Amazon MWS
Amazon Pay
Amazon Rekognition
Amazon Voice ID
Aruba Fatturazione
Azure Maps
Azure Monitor
Azure OAuth2
Azure Storage Accounts
Backblaze S3
Bitfinex v2 REST
Bluzone
CallRail
CardConnect
Cerved
ClickBank
Clickatell
Cloudfare
Constant Contact
DocuSign
Duo Auth MFA
ETrade
Ecwid
Egypt ITIDA
Etsy
Facebook
Faire
Frame.io
GeoOp
GetHarvest
Global Payments
Google People
Google Search Console
Hungary NAV Invoicing
IBM Text to Speech
Ibanity
IntakeQ
Jira
Lightspeed
MYOB
Magento
Mailgun

MedTunnel
MercadoLibre
Microsoft Calendar
Microsoft Group
Microsoft Tasks and Plans
Microsoft Teams
Okta OAuth/OIDC
OneLogin OIDC
OneNote
PRODA
PayPal
Paynow.pl
Peoplevox
Populi
QuickBooks
Rabobank
Refinitiv
Royal Mail OBA
SCiS Schools Catalogue
SII Chile
SMSAPI
SOAP finkok.com
SendGrid
Shippo
Shopify
Shopware
Shopware 6
SimpleTexting
Square
Stripe
SugarCRM
TicketBAI
Trello
Twilio
Twitter
UniPin
VoiceBase
Vonage
Walmart
Walmart v3
Wasabi
WhatsApp
WiX
WooCommerce
WordPress
Xero
Yahoo Mail
Yousign
Zoom
_Miscellaneous_
eBay
effectconnect
hacienda.go.cr

 

 

 

(DataFlex) Google People API - List the User's Contacts

Gets a list of people in the user's contacts.

For more information, see https://developers.google.com/people/v1/contacts

Chilkat ActiveX Downloads

ActiveX for 32-bit and 64-bit Windows

Use ChilkatAx-9.5.0-win32.pkg

Procedure Test
Token    Handle hoJsonToken
    Boolean iSuccess
    Handle hoHttp
    Variant vSbResponseBody
    Handle hoSbResponseBody
    Handle hoJson
    String sResourceName
    String sEtag
    Integer j
    Integer iCount_j
    Boolean iMetadataPrimary
    String sMetadataSourceType
    String sMetadataSourceId
    String sDisplayName
    String sFamilyName
    String sGivenName
    String sDisplayNameLastFirst
    String sUnstructuredName
    String sValue
    String sFormattedValue
    String sStreetAddress
    String sCity
    String sRegion
    String sPostalCode
    String sCountry
    String sCountryCode
    Integer iTotalPeople
    Integer iTotalItems
    Integer i
    Integer iCount_i
    String sTemp1

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

    // It is assumed we previously obtained an OAuth2 access token.
    // This example loads the JSON access token file 

    // originally obtained by this example: Get Google People API OAuth2 Access Token
    // or refreshed by this example: Refresh Google People API OAuth2 Access Token

    Get Create (RefClass(cComChilkatJsonObject)) To hoJsonToken
    If (Not(IsComObjectCreated(hoJsonToken))) Begin
        Send CreateComObject of hoJsonToken
    End
    Get ComLoadFile Of hoJsonToken "qa_data/tokens/googlePeople.json" To iSuccess
    If (iSuccess <> True) Begin
        Showln "Failed to load googleContacts.json"
        Procedure_Return
    End

    Get Create (RefClass(cComChilkatHttp)) To hoHttp
    If (Not(IsComObjectCreated(hoHttp))) Begin
        Send CreateComObject of hoHttp
    End

    Get ComStringOf Of hoJsonToken "access_token" To sTemp1
    Set ComAuthToken Of hoHttp To sTemp1

    Get Create (RefClass(cComChilkatStringBuilder)) To hoSbResponseBody
    If (Not(IsComObjectCreated(hoSbResponseBody))) Begin
        Send CreateComObject of hoSbResponseBody
    End
    Get pvComObject of hoSbResponseBody to vSbResponseBody
    Get ComQuickGetSb Of hoHttp "https://people.googleapis.com/v1/people/me/connections?personFields=names,addresses,emailAddresses" vSbResponseBody To iSuccess
    If (iSuccess = False) Begin
        Get ComLastErrorText Of hoHttp To sTemp1
        Showln sTemp1
        Get ComGetAsString Of hoSbResponseBody To sTemp1
        Showln sTemp1
        Procedure_Return
    End

    // Sample JSON Response

    // Use this online tool to generate parsing code from sample JSON: 
    // Generate Parsing Code from JSON

    // {
    //   "connections": [
    //     {
    //       "resourceName": "people/c8871101035606120608",
    //       "etag": "%EgkBAj0JQhBANy4aBAECBQciDERLSGdVTFNPbzNJPQ==",
    //       "names": [
    //         {
    //           "metadata": {
    //             "primary": true,
    //             "source": {
    //               "type": "CONTACT",
    //               "id": "7b1c7b6409e718a0"
    //             }
    //           },
    //           "displayName": "Chilkat Cloud",
    //           "familyName": "Cloud",
    //           "givenName": "Chilkat",
    //           "displayNameLastFirst": "Cloud, Chilkat",
    //           "unstructuredName": "Chilkat Cloud"
    //         }
    //       ],
    //       "emailAddresses": [
    //         {
    //           "metadata": {
    //             "primary": true,
    //             "source": {
    //               "type": "CONTACT",
    //               "id": "7b1c7b6409e718a0"
    //             }
    //           },
    //           "value": "support@***.com"
    //         }
    //       ]
    //     },
    //     {
    //       "resourceName": "people/c7607335470312011517",
    //       "etag": "%EgkBAj0JQhBANy4aBAECBQciDGZETUtHVTVMazI4PQ==",
    //       "names": [
    //         {
    //           "metadata": {
    //             "primary": true,
    //             "source": {
    //               "type": "CONTACT",
    //               "id": "6992af4e0b2d36fd"
    //             }
    //           },
    //           "displayName": "Matt Smith",
    //           "familyName": "Smith",
    //           "givenName": "Matt",
    //           "displayNameLastFirst": "Smith, Matt",
    //           "unstructuredName": "Matt Smith"
    //         }
    //       ],
    //       "addresses": [
    //         {
    //           "metadata": {
    //             "primary": true,
    //             "source": {
    //               "type": "CONTACT",
    //               "id": "6992af4e0b2d36fd"
    //             }
    //           },
    //           "formattedValue": "2222 E Foorest Ave\nWheaton, IL 60999\nUS",
    //           "streetAddress": "2222 E Foorest Ave",
    //           "city": "Wheaton",
    //           "region": "IL",
    //           "postalCode": "60999",
    //           "country": "US",
    //           "countryCode": "US"
    //         }
    //       ],
    //       "emailAddresses": [
    //         {
    //           "metadata": {
    //             "primary": true,
    //             "source": {
    //               "type": "CONTACT",
    //               "id": "6992af4e0b2d36fd"
    //             }
    //           },
    //           "value": "matt@***.com"
    //         },
    //         {
    //           "metadata": {
    //             "source": {
    //               "type": "CONTACT",
    //               "id": "6992af4e0b2d36fd"
    //             }
    //           },
    //           "value": "admin@***.com"
    //         }
    //       ]
    //     }
    //   ],
    //   "totalPeople": 2,
    //   "totalItems": 2
    // }

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

    Get ComIntOf Of hoJson "totalPeople" To iTotalPeople
    Get ComIntOf Of hoJson "totalItems" To iTotalItems
    Move 0 To i
    Get ComSizeOfArray Of hoJson "connections" To iCount_i
    While (i < iCount_i)
        Set ComI Of hoJson To i
        Get ComStringOf Of hoJson "connections[i].resourceName" To sResourceName
        Get ComStringOf Of hoJson "connections[i].etag" To sEtag
        Move 0 To j
        Get ComSizeOfArray Of hoJson "connections[i].names" To iCount_j
        While (j < iCount_j)
            Set ComJ Of hoJson To j
            Get ComBoolOf Of hoJson "connections[i].names[j].metadata.primary" To iMetadataPrimary
            Get ComStringOf Of hoJson "connections[i].names[j].metadata.source.type" To sMetadataSourceType
            Get ComStringOf Of hoJson "connections[i].names[j].metadata.source.id" To sMetadataSourceId
            Get ComStringOf Of hoJson "connections[i].names[j].displayName" To sDisplayName
            Get ComStringOf Of hoJson "connections[i].names[j].familyName" To sFamilyName
            Get ComStringOf Of hoJson "connections[i].names[j].givenName" To sGivenName
            Get ComStringOf Of hoJson "connections[i].names[j].displayNameLastFirst" To sDisplayNameLastFirst
            Get ComStringOf Of hoJson "connections[i].names[j].unstructuredName" To sUnstructuredName
            Move (j + 1) To j
        Loop

        Move 0 To j
        Get ComSizeOfArray Of hoJson "connections[i].emailAddresses" To iCount_j
        While (j < iCount_j)
            Set ComJ Of hoJson To j
            Get ComBoolOf Of hoJson "connections[i].emailAddresses[j].metadata.primary" To iMetadataPrimary
            Get ComStringOf Of hoJson "connections[i].emailAddresses[j].metadata.source.type" To sMetadataSourceType
            Get ComStringOf Of hoJson "connections[i].emailAddresses[j].metadata.source.id" To sMetadataSourceId
            Get ComStringOf Of hoJson "connections[i].emailAddresses[j].value" To sValue
            Move (j + 1) To j
        Loop

        Move 0 To j
        Get ComSizeOfArray Of hoJson "connections[i].addresses" To iCount_j
        While (j < iCount_j)
            Set ComJ Of hoJson To j
            Get ComBoolOf Of hoJson "connections[i].addresses[j].metadata.primary" To iMetadataPrimary
            Get ComStringOf Of hoJson "connections[i].addresses[j].metadata.source.type" To sMetadataSourceType
            Get ComStringOf Of hoJson "connections[i].addresses[j].metadata.source.id" To sMetadataSourceId
            Get ComStringOf Of hoJson "connections[i].addresses[j].formattedValue" To sFormattedValue
            Get ComStringOf Of hoJson "connections[i].addresses[j].streetAddress" To sStreetAddress
            Get ComStringOf Of hoJson "connections[i].addresses[j].city" To sCity
            Get ComStringOf Of hoJson "connections[i].addresses[j].region" To sRegion
            Get ComStringOf Of hoJson "connections[i].addresses[j].postalCode" To sPostalCode
            Get ComStringOf Of hoJson "connections[i].addresses[j].country" To sCountry
            Get ComStringOf Of hoJson "connections[i].addresses[j].countryCode" To sCountryCode
            Move (j + 1) To j
        Loop

        Move (i + 1) To i
    Loop



End_Procedure

 

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