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) Get the Photos for a UserDemonstrates how to get the photos that the user has uploaded.
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.