Chilkat Examples

ChilkatHOMEAndroid™Classic ASPCC++C#Mono C#.NET Core C#C# UWP/WinRTDataFlexDelphi ActiveXDelphi DLLVisual FoxProJavaLianjaMFCObjective-CPerlPHP ActiveXPHP ExtensionPowerBuilderPowerShellPureBasicCkPythonChilkat2-PythonRubySQL ServerSwift 2Swift 3,4,5...TclUnicode CUnicode C++Visual Basic 6.0VB.NETVB.NET UWP/WinRTVBScriptXojo PluginNode.jsExcelGo

Swift 3,4,5... Web API Examples

Primary Categories

ABN AMRO
AWS Translate
Activix CRM
Adyen
Amazon MWS
Aruba Fatturazione
Azure Maps
Azure Monitor
Azure OAuth2
Azure Storage Accounts
Bitfinex v2 REST
Bluzone
CallRail
CardConnect
ClickBank
Clickatell
Cloudfare
DocuSign
ETrade
Etsy
Facebook
GeoOp
GetHarvest
Global Payments
Google People
Google Search Console
Hungary NAV Invoicing
IBM Text to Speech
Jira
MYOB

Magento
MercadoLibre
Microsoft Calendar
Microsoft Group
Microsoft Tasks and Plans
Okta OAuth/OIDC
OneLogin OIDC
PayPal
Peoplevox
Populi
QuickBooks
Rabobank
SOAP finkok.com
Shippo
Shopify
SimpleTexting
Square
Stripe
SugarCRM
Trello
Twilio
Twitter
VoiceBase
Vonage
Walmart
Walmart v3
WhatsApp
WooCommerce
Xero
Yousign
_Miscellaneous_
eBay
effectconnect

 

 

 

(Swift 3,4,5...) Google Search Console API - List

Lists the user's Search Console sites.

For more information, see https://developers.google.com/webmaster-tools/search-console-api-original/v3/sites/list

Chilkat Downloads for the Swift Programming Language

MAC OS X (Cocoa) Objective-C/Swift Libs

iOS Objective-C/Swift Libs

func chilkatTest() {
    // This example requires the Chilkat API to have been previously unlocked.
    // See Global Unlock Sample for sample code.

    // This example uses a previously obtained access token having permission for the 
    // Google Search Console scope.

    // In this example, Get a Google Search Console OAuth2 Access Token, the access
    // token was saved to a JSON file.  This example fetches the access token from the file..
    let jsonToken = CkoJsonObject()!
    var success: Bool = jsonToken.loadFile("qa_data/tokens/googleSearchConsole.json")
    if jsonToken.hasMember("access_token") == false {
        print("No access token found.")
        return
    }

    let http = CkoHttp()!
    http.authToken = jsonToken.string(of: "access_token")

    var responseStr: String? = http.quickGetStr("https://www.googleapis.com/webmasters/v3/sites")
    if http.lastMethodSuccess == false {
        print("\(http.lastErrorText!)")
        return
    }

    var statusCode: Int = http.lastStatus.intValue
    print("Response Status Code: \(statusCode)")

    // Sample response:

    // {
    //  "siteEntry": [
    //   {
    //    "siteUrl": "https://www.example.com/",
    //    "permissionLevel": "siteUnverifiedUser"
    //   },
    //   {
    //    "siteUrl": "http://www.chilkatsoft.com/",
    //    "permissionLevel": "siteOwner"
    //   }
    //  ]
    // }

    print("\(responseStr!)")

    // Use this online tool to generate parsing code from sample JSON: 
    // Generate Parsing Code from JSON

    let json = CkoJsonObject()!

    success = json.load(responseStr)

    var siteUrl: String?
    var permissionLevel: String?

    var i: Int = 0
    var count_i: Int = json.size(ofArray: "siteEntry").intValue
    while i < count_i {
        json.i = i
        siteUrl = json.string(of: "siteEntry[i].siteUrl")
        print("siteUrl: \(siteUrl!)")
        permissionLevel = json.string(of: "siteEntry[i].permissionLevel")
        print("permissionLevel: \(permissionLevel!)")
        i = i + 1
    }


}

 

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