Chilkat HOME .NET Core C# Android™ AutoIt C C# C++ Chilkat2-Python CkPython Classic ASP DataFlex Delphi ActiveX Delphi DLL Go Java Lianja Mono C# Node.js Objective-C PHP ActiveX PHP Extension Perl PowerBuilder PowerShell PureBasic Ruby SQL Server Swift 2 Swift 3,4,5... Tcl Unicode C Unicode C++ VB.NET VBScript Visual Basic 6.0 Visual FoxPro Xojo Plugin
(DataFlex) Google People API - List the User's ContactsGets a list of people in the user's contacts. For more information, see https://developers.google.com/people/v1/contacts
Use ChilkatAx-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-2024 Chilkat Software, Inc. All Rights Reserved.