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

Objective-C 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

 

 

 

(Objective-C) WordPress API Key Authentication with miniOrange Plugin

See more WordPress Examples

Demonstrates API key authentication using the miniOrange API Authentication plugin.

For more information, see https://wordpress.org/plugins/wp-rest-api-authentication/

Chilkat Objective-C Library Downloads

MAC OS X (Cocoa) Libs

iOS Libs

#import <CkoHttp.h>
#import <CkoStringBuilder.h>
#import <CkoJsonArray.h>
#import <CkoDtObj.h>
#import <CkoJsonObject.h>
#import <NSString.h>

// This example assumes the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.

CkoHttp *http = [[CkoHttp alloc] init];
BOOL success;

// Use your API key here, such as TaVFjSBu8IMR0MbvZNn7A6P04GXrbtHm
// This causes the "Authorization: Bearer <api_key>" header to be added to each HTTP request.
http.AuthToken = @"api_key";

CkoStringBuilder *sbResponseBody = [[CkoStringBuilder alloc] init];
success = [http QuickGetSb: @"https://www.yoursite.com/wp-json/wp/v2/posts?page=1" sbContent: sbResponseBody];
if (success == NO) {
    NSLog(@"%@",http.LastErrorText);
    return;
}

CkoJsonArray *jarrResp = [[CkoJsonArray alloc] init];
[jarrResp LoadSb: sbResponseBody];
jarrResp.EmitCompact = NO;

NSLog(@"%@",@"Response Body:");
NSLog(@"%@",[jarrResp Emit]);

int respStatusCode = [http.LastStatus intValue];
NSLog(@"%@%d",@"Response Status Code = ",respStatusCode);
if (respStatusCode >= 400) {
    NSLog(@"%@",@"Response Header:");
    NSLog(@"%@",http.LastHeader);
    NSLog(@"%@",@"Failed.");
    return;
}

// Sample JSON response:
// (Sample code for parsing the JSON response is shown below)

// [
//   {
//     "id": 1902,
//     "date": "2020-11-16T09:54:09",
//     "date_gmt": "2020-11-16T16:54:09",
//     "guid": {
//       "rendered": "http:\/\/cknotes.com\/?p=1902"
//     },
//     "modified": "2020-11-16T09:54:09",
//     "modified_gmt": "2020-11-16T16:54:09",
//     "slug": "xero-redirect-uri-for-oauth2-and-desktop-apps",
//     "status": "publish",
//     "type": "post",
//     "link": "https:\/\/cknotes.com\/xero-redirect-uri-for-oauth2-and-desktop-apps\/",
//     "title": {
//       "rendered": "Xero Redirect URI for OAuth2 and Desktop Apps"
//     },
//     "content": {
//       "rendered": "<p>...",
//       "protected": false
//     },
//     "excerpt": {
//       "rendered": "<p>...",
//       "protected": false
//     },
//     "author": 1,
//     "featured_media": 0,
//     "comment_status": "closed",
//     "ping_status": "open",
//     "sticky": false,
//     "template": "",
//     "format": "standard",
//     "meta": [
//     ],
//     "categories": [
//       815
//     ],
//     "tags": [
//       594,
//       816
//     ],
//     "_links": {
//       "self": [
//         {
//           "href": "https:\/\/cknotes.com\/wp-json\/wp\/v2\/posts\/1902"
//         }
//       ],
//       "collection": [
//         {
//           "href": "https:\/\/cknotes.com\/wp-json\/wp\/v2\/posts"
//         }
//       ],
//       "about": [
//         {
//           "href": "https:\/\/cknotes.com\/wp-json\/wp\/v2\/types\/post"
//         }
//       ],
//       "author": [
//         {
//           "embeddable": true,
//           "href": "https:\/\/cknotes.com\/wp-json\/wp\/v2\/users\/1"
//         }
//       ],
//       "replies": [
//         {
//           "embeddable": true,
//           "href": "https:\/\/cknotes.com\/wp-json\/wp\/v2\/comments?post=1902"
//         }
//       ],
//       "version-history": [
//         {
//           "count": 1,
//           "href": "https:\/\/cknotes.com\/wp-json\/wp\/v2\/posts\/1902\/revisions"
//         }
//       ],
//       "predecessor-version": [
//         {
//           "id": 1904,
//           "href": "https:\/\/cknotes.com\/wp-json\/wp\/v2\/posts\/1902\/revisions\/1904"
//         }
//       ],
//       "wp:attachment": [
//         {
//           "href": "https:\/\/cknotes.com\/wp-json\/wp\/v2\/media?parent=1902"
//         }
//       ],
//       "wp:term": [
//         {
//           "taxonomy": "category",
//           "embeddable": true,
//           "href": "https:\/\/cknotes.com\/wp-json\/wp\/v2\/categories?post=1902"
//         },
//         {
//           "taxonomy": "post_tag",
//           "embeddable": true,
//           "href": "https:\/\/cknotes.com\/wp-json\/wp\/v2\/tags?post=1902"
//         }
//       ],
//       "curies": [
//         {
//           "name": "wp",
//           "href": "https:\/\/api.w.org\/{rel}",
//           "templated": true
//         }
//       ]
//     }
//   },
// ...
// ]

// Sample code for parsing the JSON response...
// Use the following online tool to generate parsing code from sample JSON:
// Generate Parsing Code from JSON

CkoDtObj *date_gmt = [[CkoDtObj alloc] init];
CkoJsonObject *json = 0;
int id;
NSString *date = 0;
NSString *guidRendered = 0;
NSString *modified = 0;
NSString *modified_gmt = 0;
NSString *slug = 0;
NSString *status = 0;
NSString *v_type = 0;
NSString *link = 0;
NSString *titleRendered = 0;
NSString *contentRendered = 0;
BOOL contentProtected;
NSString *excerptRendered = 0;
BOOL excerptProtected;
int author;
int featured_media;
NSString *comment_status = 0;
NSString *ping_status = 0;
BOOL sticky;
NSString *template = 0;
NSString *format = 0;
int j;
int count_j;
int intVal;
NSString *href = 0;
BOOL embeddable;
int count;
NSString *taxonomy = 0;
NSString *name = 0;
BOOL templated;

int i = 0;
int count_i = [jarrResp.Size intValue];
while (i < count_i) {
    json = [jarrResp ObjectAt: [NSNumber numberWithInt: i]];
    id = [[json IntOf: @"id"] intValue];
    date = [json StringOf: @"date"];
    [json DtOf: @"date_gmt" bLocal: NO dt: date_gmt];
    guidRendered = [json StringOf: @"guid.rendered"];
    modified = [json StringOf: @"modified"];
    modified_gmt = [json StringOf: @"modified_gmt"];
    slug = [json StringOf: @"slug"];
    status = [json StringOf: @"status"];
    v_type = [json StringOf: @"type"];
    link = [json StringOf: @"link"];
    titleRendered = [json StringOf: @"title.rendered"];
    contentRendered = [json StringOf: @"content.rendered"];
    contentProtected = [json BoolOf: @"content.protected"];
    excerptRendered = [json StringOf: @"excerpt.rendered"];
    excerptProtected = [json BoolOf: @"excerpt.protected"];
    author = [[json IntOf: @"author"] intValue];
    featured_media = [[json IntOf: @"featured_media"] intValue];
    comment_status = [json StringOf: @"comment_status"];
    ping_status = [json StringOf: @"ping_status"];
    sticky = [json BoolOf: @"sticky"];
    template = [json StringOf: @"template"];
    format = [json StringOf: @"format"];
    j = 0;
    count_j = [[json SizeOfArray: @"meta"] intValue];
    while (j < count_j) {
        json.J = [NSNumber numberWithInt: j];
        j = j + 1;
    }

    j = 0;
    count_j = [[json SizeOfArray: @"categories"] intValue];
    while (j < count_j) {
        json.J = [NSNumber numberWithInt: j];
        intVal = [[json IntOf: @"categories[j]"] intValue];
        j = j + 1;
    }

    j = 0;
    count_j = [[json SizeOfArray: @"tags"] intValue];
    while (j < count_j) {
        json.J = [NSNumber numberWithInt: j];
        intVal = [[json IntOf: @"tags[j]"] intValue];
        j = j + 1;
    }

    j = 0;
    count_j = [[json SizeOfArray: @"_links.self"] intValue];
    while (j < count_j) {
        json.J = [NSNumber numberWithInt: j];
        href = [json StringOf: @"_links.self[j].href"];
        j = j + 1;
    }

    j = 0;
    count_j = [[json SizeOfArray: @"_links.collection"] intValue];
    while (j < count_j) {
        json.J = [NSNumber numberWithInt: j];
        href = [json StringOf: @"_links.collection[j].href"];
        j = j + 1;
    }

    j = 0;
    count_j = [[json SizeOfArray: @"_links.about"] intValue];
    while (j < count_j) {
        json.J = [NSNumber numberWithInt: j];
        href = [json StringOf: @"_links.about[j].href"];
        j = j + 1;
    }

    j = 0;
    count_j = [[json SizeOfArray: @"_links.author"] intValue];
    while (j < count_j) {
        json.J = [NSNumber numberWithInt: j];
        embeddable = [json BoolOf: @"_links.author[j].embeddable"];
        href = [json StringOf: @"_links.author[j].href"];
        j = j + 1;
    }

    j = 0;
    count_j = [[json SizeOfArray: @"_links.replies"] intValue];
    while (j < count_j) {
        json.J = [NSNumber numberWithInt: j];
        embeddable = [json BoolOf: @"_links.replies[j].embeddable"];
        href = [json StringOf: @"_links.replies[j].href"];
        j = j + 1;
    }

    j = 0;
    count_j = [[json SizeOfArray: @"_links.version-history"] intValue];
    while (j < count_j) {
        json.J = [NSNumber numberWithInt: j];
        count = [[json IntOf: @"_links.version-history[j].count"] intValue];
        href = [json StringOf: @"_links.version-history[j].href"];
        j = j + 1;
    }

    j = 0;
    count_j = [[json SizeOfArray: @"_links.predecessor-version"] intValue];
    while (j < count_j) {
        json.J = [NSNumber numberWithInt: j];
        id = [[json IntOf: @"_links.predecessor-version[j].id"] intValue];
        href = [json StringOf: @"_links.predecessor-version[j].href"];
        j = j + 1;
    }

    j = 0;
    count_j = [[json SizeOfArray: @"_links.wp:attachment"] intValue];
    while (j < count_j) {
        json.J = [NSNumber numberWithInt: j];
        href = [json StringOf: @"_links.wp:attachment[j].href"];
        j = j + 1;
    }

    j = 0;
    count_j = [[json SizeOfArray: @"_links.wp:term"] intValue];
    while (j < count_j) {
        json.J = [NSNumber numberWithInt: j];
        taxonomy = [json StringOf: @"_links.wp:term[j].taxonomy"];
        embeddable = [json BoolOf: @"_links.wp:term[j].embeddable"];
        href = [json StringOf: @"_links.wp:term[j].href"];
        j = j + 1;
    }

    j = 0;
    count_j = [[json SizeOfArray: @"_links.curies"] intValue];
    while (j < count_j) {
        json.J = [NSNumber numberWithInt: j];
        name = [json StringOf: @"_links.curies[j].name"];
        href = [json StringOf: @"_links.curies[j].href"];
        templated = [json BoolOf: @"_links.curies[j].templated"];
        j = j + 1;
    }

    i = i + 1;
}
 

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