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
(Classic ASP) 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
<html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> </head> <body> <% ' 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 ' For versions of Chilkat < 10.0.0, use CreateObject("Chilkat_9_5_0.JsonObject") set jsonToken = Server.CreateObject("Chilkat.JsonObject") success = jsonToken.LoadFile("qa_data/tokens/googlePeople.json") If (success <> 1) Then Response.Write "<pre>" & Server.HTMLEncode( "Failed to load googleContacts.json") & "</pre>" Response.End End If ' For versions of Chilkat < 10.0.0, use CreateObject("Chilkat_9_5_0.Http") set http = Server.CreateObject("Chilkat.Http") http.AuthToken = jsonToken.StringOf("access_token") ' For versions of Chilkat < 10.0.0, use CreateObject("Chilkat_9_5_0.StringBuilder") set sbResponseBody = Server.CreateObject("Chilkat.StringBuilder") success = http.QuickGetSb("https://people.googleapis.com/v1/people/me/connections?personFields=names,addresses,emailAddresses",sbResponseBody) If (success = 0) Then Response.Write "<pre>" & Server.HTMLEncode( http.LastErrorText) & "</pre>" Response.Write "<pre>" & Server.HTMLEncode( sbResponseBody.GetAsString()) & "</pre>" Response.End End If ' 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 ' } ' For versions of Chilkat < 10.0.0, use CreateObject("Chilkat_9_5_0.JsonObject") set json = Server.CreateObject("Chilkat.JsonObject") json.EmitCompact = 0 success = json.Load(sbResponseBody.GetAsString()) Response.Write "<pre>" & Server.HTMLEncode( json.Emit()) & "</pre>" totalPeople = json.IntOf("totalPeople") totalItems = json.IntOf("totalItems") i = 0 count_i = json.SizeOfArray("connections") Do While i < count_i json.I = i resourceName = json.StringOf("connections[i].resourceName") etag = json.StringOf("connections[i].etag") j = 0 count_j = json.SizeOfArray("connections[i].names") Do While j < count_j json.J = j metadataPrimary = json.BoolOf("connections[i].names[j].metadata.primary") metadataSourceType = json.StringOf("connections[i].names[j].metadata.source.type") metadataSourceId = json.StringOf("connections[i].names[j].metadata.source.id") displayName = json.StringOf("connections[i].names[j].displayName") familyName = json.StringOf("connections[i].names[j].familyName") givenName = json.StringOf("connections[i].names[j].givenName") displayNameLastFirst = json.StringOf("connections[i].names[j].displayNameLastFirst") unstructuredName = json.StringOf("connections[i].names[j].unstructuredName") j = j + 1 Loop j = 0 count_j = json.SizeOfArray("connections[i].emailAddresses") Do While j < count_j json.J = j metadataPrimary = json.BoolOf("connections[i].emailAddresses[j].metadata.primary") metadataSourceType = json.StringOf("connections[i].emailAddresses[j].metadata.source.type") metadataSourceId = json.StringOf("connections[i].emailAddresses[j].metadata.source.id") value = json.StringOf("connections[i].emailAddresses[j].value") j = j + 1 Loop j = 0 count_j = json.SizeOfArray("connections[i].addresses") Do While j < count_j json.J = j metadataPrimary = json.BoolOf("connections[i].addresses[j].metadata.primary") metadataSourceType = json.StringOf("connections[i].addresses[j].metadata.source.type") metadataSourceId = json.StringOf("connections[i].addresses[j].metadata.source.id") formattedValue = json.StringOf("connections[i].addresses[j].formattedValue") streetAddress = json.StringOf("connections[i].addresses[j].streetAddress") city = json.StringOf("connections[i].addresses[j].city") region = json.StringOf("connections[i].addresses[j].region") postalCode = json.StringOf("connections[i].addresses[j].postalCode") country = json.StringOf("connections[i].addresses[j].country") countryCode = json.StringOf("connections[i].addresses[j].countryCode") j = j + 1 Loop i = i + 1 Loop %> </body> </html> |
© 2000-2024 Chilkat Software, Inc. All Rights Reserved.