Chilkat Examples

ChilkatHOME.NET Core C#Android™AutoItCC#C++Chilkat2-PythonCkPythonClassic ASPDataFlexDelphi ActiveXDelphi DLLGoJavaLianjaMono C#Node.jsObjective-CPHP ActiveXPHP ExtensionPerlPowerBuilderPowerShellPureBasicRubySQL ServerSwift 2Swift 3,4,5...TclUnicode CUnicode C++VB.NETVBScriptVisual Basic 6.0Visual FoxProXojo Plugin

DataFlex Web API Examples

Primary Categories

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

Mastercard
MedTunnel
MercadoLibre
MessageMedia
Microsoft Calendar
Microsoft Group
Microsoft Tasks and Plans
Microsoft Teams
Moody's
Okta OAuth/OIDC
OneLogin OIDC
OneNote
OpenAI ChatGPT
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 API v2
Twitter v1
UPS
UniPin
VoiceBase
Vonage
WaTrend
Walmart v3
Wasabi
WhatsApp
WiX
WooCommerce
WordPress
Xero
Yahoo Mail
Yapily
Yousign
ZATCA
Zendesk
Zoom
_Miscellaneous_
eBay
effectconnect
hacienda.go.cr

 

 

 

(DataFlex) Read a Single Facebook Post

Demonstrates how to read the contents of a single Facebook post. A post is an individual entry in a profile's feed. The profile could be a user, page, app, or group.

Chilkat ActiveX Downloads

ActiveX for 32-bit and 64-bit Windows

Use ChilkatAx-9.5.0-win32.pkg

Procedure Test
    Variant vOauth2
    Handle hoOauth2
    Handle hoRest
    Boolean iSuccess
    String sPostId
    Handle hoSbPath
    String sResponseJson
    Handle hoJson
    Handle hoDtime
    Boolean iBLocalTime
    Variant vDt
    Handle hoDt
    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

    // This example assumes a post id was already retrieved.
    // For example, it could've been retrieved by reading the user's feed:
    // See Parsing the Facebook User Feed for code showing how to parse the JSON feed content.

    Move "10224048320139890_10210156138515282" To sPostId

    Get Create (RefClass(cComChilkatStringBuilder)) To hoSbPath
    If (Not(IsComObjectCreated(hoSbPath))) Begin
        Send CreateComObject of hoSbPath
    End
    Get ComAppend Of hoSbPath "/v2.7/" To iSuccess
    Get ComAppend Of hoSbPath sPostId To iSuccess

    // Select the fields we want.
    // This example will select almost all the possible fields.
    // See https://developers.facebook.com/docs/graph-api/reference/post/
    Get ComAddQueryParam Of hoRest "fields" "id,message,created_time,caption,description,from,link,name,object_id,picture,place,privacy,properties,shares,source,status_type,story,targeting,to,type,updated_time,with_tags" To iSuccess

    Get ComGetAsString Of hoSbPath To sTemp1
    Get ComFullRequestNoBody Of hoRest "GET" sTemp1 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

    // Show the JSON in human-readable format.
    Get ComEmit Of hoJson To sTemp1
    Showln sTemp1

    // A sample JSON response is shown here.  
    // { 
    //   "id": "12345678901234567_12345678900000004",
    //   "message": "Ignore my posts -- I'm doing some testing for Facebook related programming...",
    //   "created_time": "2016-09-29T20:46:18+0000",
    //   "from": { 
    //     "name": "John Doe",
    //     "id": "12345678901234567"
    //   },
    //   "link": "https:\/\/www.facebook.com\/photo.php?fbid=10210199026247451&set=a.1237223526054.2038240.1094202869&type=3",
    //   "object_id": "10210139026347451",
    //   "picture": "https:\/\/scontent.xx.fbcdn.net\/v\/t1.0-9\/14462791_10210199026647451_7830642117574407060_n.jpg?oh=a7f9ed10ce9cd81a82adeb541c60e2e2&oe=58ABB195",
    //   "privacy": { 
    //     "allow": "",
    //     "deny": "",
    //     "description": "Public",
    //     "friends": "",
    //     "value": "EVERYONE"
    //   },
    //   "status_type": "added_photos",
    //   "type": "photo",
    //   "updated_time": "2016-09-29T20:46:18+0000"
    // }

    // This is the code to parse some fields in the JSON response.
    Get ComStringOf Of hoJson "type" To sTemp1
    Showln "type: " sTemp1
    Get ComStringOf Of hoJson "message" To sTemp1
    Showln "message: " sTemp1
    Get ComStringOf Of hoJson "id" To sTemp1
    Showln "id: " sTemp1
    Get ComStringOf Of hoJson "link" To sTemp1
    Showln "link: " sTemp1
    Get ComStringOf Of hoJson "privacy.description" To sTemp1
    Showln "privacy descripton: " sTemp1

    Get Create (RefClass(cComCkDateTime)) To hoDtime
    If (Not(IsComObjectCreated(hoDtime))) Begin
        Send CreateComObject of hoDtime
    End
    Move True To iBLocalTime
    Get ComStringOf Of hoJson "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


End_Procedure

 

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