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

SQL Server 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
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

 

 

 

(SQL Server) Get the Photos for a User

Demonstrates how to get the photos that the user has uploaded.

Chilkat ActiveX Downloads

ActiveX for 32-bit and 64-bit Windows

// Important: See this note about string length limitations for strings returned by sp_OAMethod calls.
//
CREATE PROCEDURE ChilkatSample
AS
BEGIN
    DECLARE @hr int
    DECLARE @iTmp0 int
    DECLARE @iTmp1 int
    DECLARE @iTmp2 int
    DECLARE @iTmp3 int
    DECLARE @iTmp4 int
    DECLARE @sTmp0 nvarchar(4000)
    -- 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
    DECLARE @oauth2 int
    EXEC @hr = sp_OACreate 'Chilkat_9_5_0.OAuth2', @oauth2 OUT
    IF @hr <> 0
    BEGIN
        PRINT 'Failed to create ActiveX component'
        RETURN
    END

    EXEC sp_OASetProperty @oauth2, 'AccessToken', 'FACEBOOK-ACCESS-TOKEN'

    DECLARE @rest int
    EXEC @hr = sp_OACreate 'Chilkat_9_5_0.Rest', @rest OUT

    -- Connect to Facebook.
    DECLARE @success int
    EXEC sp_OAMethod @rest, 'Connect', @success OUT, 'graph.facebook.com', 443, 1, 1
    IF @success <> 1
      BEGIN
        EXEC sp_OAGetProperty @rest, 'LastErrorText', @sTmp0 OUT
        PRINT @sTmp0
        EXEC @hr = sp_OADestroy @oauth2
        EXEC @hr = sp_OADestroy @rest
        RETURN
      END

    -- Provide the authentication credentials (i.e. the access key)
    EXEC sp_OAMethod @rest, 'SetAuthOAuth2', @success OUT, @oauth2

    -- Indicate that we only want the photos the user has personally uploaded.
    EXEC sp_OAMethod @rest, 'AddQueryParam', @success OUT, 'type', 'uploaded'

    -- We could limit the number of photos by setting a limit.
    EXEC sp_OAMethod @rest, 'AddQueryParam', @success OUT, 'limit', '5'

    -- 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.
    DECLARE @responseJson nvarchar(4000)
    EXEC sp_OAMethod @rest, 'FullRequestNoBody', @responseJson OUT, 'GET', '/v2.7/me/photos'
    EXEC sp_OAGetProperty @rest, 'LastMethodSuccess', @iTmp0 OUT
    IF @iTmp0 <> 1
      BEGIN
        EXEC sp_OAGetProperty @rest, 'LastErrorText', @sTmp0 OUT
        PRINT @sTmp0
        EXEC @hr = sp_OADestroy @oauth2
        EXEC @hr = sp_OADestroy @rest
        RETURN
      END

    DECLARE @json int
    EXEC @hr = sp_OACreate 'Chilkat_9_5_0.JsonObject', @json OUT

    EXEC sp_OASetProperty @json, 'EmitCompact', 0
    EXEC sp_OAMethod @json, 'Load', @success OUT, @responseJson
    EXEC sp_OAMethod @json, 'Emit', @sTmp0 OUT
    PRINT @sTmp0

    -- A sample JSON response is shown below.  
    -- This is the code to parse the JSON response.

    DECLARE @dtime int
    EXEC @hr = sp_OACreate 'Chilkat_9_5_0.CkDateTime', @dtime OUT

    DECLARE @bLocalTime int
    SELECT @bLocalTime = 1

    DECLARE @dt int

    DECLARE @i int
    SELECT @i = 0
    DECLARE @numItems int
    EXEC sp_OAMethod @json, 'SizeOfArray', @numItems OUT, 'data'
    WHILE @i < @numItems
      BEGIN
        EXEC sp_OASetProperty @json, 'I', @i

        PRINT '--- ' + @i
        DECLARE @name nvarchar(4000)
        EXEC sp_OAMethod @json, 'StringOf', @name OUT, 'data[i].name'
        EXEC sp_OAGetProperty @json, 'LastMethodSuccess', @iTmp0 OUT
        IF @iTmp0 = 1
          BEGIN

            PRINT 'name: ' + @name
          END

        EXEC sp_OAMethod @json, 'StringOf', @sTmp0 OUT, 'data[i].id'
        PRINT 'id: ' + @sTmp0

        -- We can load the created_time into a CkDateTime...
        EXEC sp_OAMethod @json, 'StringOf', @sTmp0 OUT, 'data[i].created_time'
        EXEC sp_OAMethod @dtime, 'SetFromTimestamp', @success OUT, @sTmp0
        EXEC sp_OAMethod @dtime, 'GetDtObj', @dt OUT, @bLocalTime
        EXEC sp_OAGetProperty @dt, 'Month', @iTmp0 OUT

        EXEC sp_OAGetProperty @dt, 'Day', @iTmp1 OUT

        EXEC sp_OAGetProperty @dt, 'Year', @iTmp2 OUT

        EXEC sp_OAGetProperty @dt, 'Hour', @iTmp3 OUT

        EXEC sp_OAGetProperty @dt, 'Minute', @iTmp4 OUT
        PRINT @iTmp0 + '/' + @iTmp1 + '/' + @iTmp2 + '  ' + @iTmp3 + ':' + @iTmp4
        EXEC @hr = sp_OADestroy @dt

        SELECT @i = @i + 1
      END

    -- We can get the paging information as follows:

    EXEC sp_OAMethod @json, 'StringOf', @sTmp0 OUT, 'paging.next'
    PRINT 'URL for next page: ' + @sTmp0

    EXEC sp_OAMethod @json, 'StringOf', @sTmp0 OUT, 'paging.cursors.before'
    PRINT 'before cursor: ' + @sTmp0

    EXEC sp_OAMethod @json, 'StringOf', @sTmp0 OUT, 'paging.cursors.after'
    PRINT 'after cursor: ' + @sTmp0

    -- 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"
    --   }
    -- }
    -- 

    EXEC @hr = sp_OADestroy @oauth2
    EXEC @hr = sp_OADestroy @rest
    EXEC @hr = sp_OADestroy @json
    EXEC @hr = sp_OADestroy @dtime


END
GO

 

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