Module wordpress

ballerinax/wordpress Ballerina library

1.5.1

Overview

This is a generated connector for WordPress API v1.0 OpenAPI specification.

The WordPress REST API provides an interface for applications to interact with your WordPress site. WordPress API provides a rich set of tools and interfaces for building sites, and you should not feel pressured to use the REST API if your site is already working the way you expect. You do not need to use the REST API to build a WordPress theme or plugin.

Prerequisites

Before using this connector in your Ballerina application, complete the following:

Quickstart

To use the WordPress connector in your Ballerina application, update the .bal file as follows

Step 1: Import connector

First, import the ballerinax/wordpress module into the Ballerina project.

Copy
import ballerinax/wordpress;

Step 2: Create a new connector instance

Create a wordpress:ClientConfig with the auth key and initialize the connector with it.

Copy
wordpress:ClientConfig configuration = {auth : {
        token = "<Enter your token here>"
    }
};
wordpress:Client wpClient = check new(configuration, serviceUrl);

Step 3: Invoke connector operation

  1. Now you can use the operations available within the connector. Note that they are in the form of remote operations.

    Following is an example on how to get all posts.

    Get all posts

    Copy
    public function main() {
        wordpress:Post[]|error posts = check wpClient->getPosts();
        if (posts is wordpress:Post[]) {
            foreach var post in posts {
                log:printInfo(post.toString());
            }
        } else {
            log:printError(posts.message());
        }
    }
  2. Use bal run command to compile and run the Ballerina program.

Import

import ballerinax/wordpress;Copy

Metadata

Released date: 10 months ago

Version: 1.5.1

License: Apache-2.0


Compatibility

Platform: any

Ballerina version: 2201.4.1

GraalVM compatible: Yes


Pull count

Total: 

Current verison: 2


Weekly downloads


Source repository


Keywords

Website & App Building/Website Builders
Cost/Freemium

Contributors

Other versions

See more...