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) Create Google Photos AlbumDemonstrates how to create a Google Photos album.
Use ChilkatAx-win32.pkg Procedure Test Token Handle hoJsonToken Boolean iSuccess Handle hoHttp Handle hoJson Variant vResp Handle hoResp String sId String sTitle String sProductUrl Boolean iIsWriteable String sTemp1 Integer iTemp1 Boolean bTemp1 // This example requires the Chilkat API to have been previously unlocked. // See Global Unlock Sample for sample code. // Get the previously obtained access token. // See Get Google Photos 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/googlePhotos.json" To iSuccess If (iSuccess = False) Begin Get ComLastErrorText Of hoJsonToken To sTemp1 Showln sTemp1 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 // Create an album named "animals" Get Create (RefClass(cComChilkatJsonObject)) To hoJson If (Not(IsComObjectCreated(hoJson))) Begin Send CreateComObject of hoJson End Get ComUpdateString Of hoJson "album.title" "animals" To iSuccess Get ComEmit Of hoJson To sTemp1 Get ComPostJson Of hoHttp "https://photoslibrary.googleapis.com/v1/albums" sTemp1 To vResp If (IsComObject(vResp)) Begin Get Create (RefClass(cComChilkatHttpResponse)) To hoResp Set pvComObject Of hoResp To vResp End Get ComLastMethodSuccess Of hoHttp To bTemp1 If (bTemp1 = False) Begin Get ComLastErrorText Of hoHttp To sTemp1 Showln sTemp1 Procedure_Return End // Show the response body. Get ComBodyStr Of hoResp To sTemp1 Showln sTemp1 // Examine the response status code. Success is indicated by a status code of 200. Get ComStatusCode Of hoResp To iTemp1 Showln "response status code: " iTemp1 Get ComBodyStr Of hoResp To sTemp1 Get ComLoad Of hoJson sTemp1 To iSuccess Send Destroy of hoResp // Sample response: // { // "id": "AKcbugHaQTvUKSi3M2RQxOhxhdEaLc5mfUcqFoIU_kpQaROyUD70BcFt7_mnz5PcwwsjPKeKnLHN", // "title": "animals", // "productUrl": "https://photos.google.com/lr/album/AKcbugHaQTvUKSi3M2RQxOhxhdEaLc5mfUcqFoIU_kpQaROyUD70BcFt7_mnz5PcwwsjPKeKnLHN", // "isWriteable": true // } // Use this online tool to generate parsing code from sample JSON: // Generate Parsing Code from JSON Get ComStringOf Of hoJson "id" To sId Get ComStringOf Of hoJson "title" To sTitle Get ComStringOf Of hoJson "productUrl" To sProductUrl Get ComBoolOf Of hoJson "isWriteable" To iIsWriteable Showln "id = " sId End_Procedure |
© 2000-2024 Chilkat Software, Inc. All Rights Reserved.