Skip to content
navjot50 edited this page Mar 22, 2022 · 11 revisions

Welcome to the WordPressPCL wiki!

Requirements

WordPressPCL requires:

To access protected routes, there are two authentication options:

  • Authentication using JSON Web Tokens (JWT) (plugin required)
  • Basic Authentication using Application Passwords

Supported JWT Plugins:

Supported platforms

WordPressPCL is built on top of the new .NET Standard targeting netstandard 1.1 and 2.0 versions - therefore it should work on the following plaforms:

  • .NET Framework 4.5 and newer
  • .NET Core
  • Universal Windows Platform (uap)
  • Windows 8.0 and newer
  • Windows Phone (WinRT, not Silverlight)
  • Mono / Xamarin

Setup

The WordPressPCL API Wrapper is avaiable through nuget:

> Install-Package WordPressPCL

If you execute requests required authentication you must install JWT Auth plugin and configure it. You must enable Auth Headers and defune your secret key More info https://wordpress.org/plugins/jwt-authentication-for-wp-rest-api/#description

Basic usage

using WordPressPCL;

// Initialize
var client = new WordPressClient("http://demo.wp-api.org/wp-json/");

//Auth
client.Auth.UseBearerAuth(JWTPlugin.JWTAuthByEnriqueChavez);
await client.Auth.RequestJWTokenAsync("username", "password");
var isValidToken = await client.IsValidJWTokenAsync();

// Get All Posts
var posts = await client.Posts.GetAll();