2017 © Pedro Peláez
 

wp-cli-package wp-cli-http-command

WP-CLI command for using the WordPress HTTP API

image

aaemnnosttv/wp-cli-http-command

WP-CLI command for using the WordPress HTTP API

  • Thursday, October 20, 2016
  • by aaemnnosttv
  • Repository
  • 1 Watchers
  • 2 Stars
  • 21 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 1 Forks
  • 2 Open issues
  • 2 Versions
  • 24 % Grown

The README.md

WP-CLI HTTP Command

NAME

  wp http

DESCRIPTION

  Perform an HTTP request using the WP HTTP API

SYNOPSIS

  wp http <command>

SUBCOMMANDS

  get       Perform a GET request to the given URI
  head      Perform a HEAD request to the given URI
  post      Perform a POST request to the given URI

Subcommands

Each subcommand matches to the HTTP method you wish to perform, and they all accept just 1 required parameter, the <uri>., (*1)

<uri>

The URI can be either a full URL, or just the request URI (requires realm option), (*2)

Options

Realm

--realm=<home|admin>

The realm option restricts the request to the current site, and refers to which area of the site the request URI is relative to., (*3)

To perform a GET request on the home page of the site:, (*4)

wp http get / --realm=home

or, to perform a GET request on the Plugins page of wp-admin:, (*5)

wp http get plugins.php --realm=admin

Since admin requests require authentication, we need to specify which user the request should be performed as., (*6)

Authentecated User

--as=<user>

When making any request to an admin realm, (unless you're specifically testing that the request is being redirected to the login page) you will want to specify which user the request should be made as. This is as simple as providing the user ID, username, or email., (*7)

Load the admin Dashboard, (*8)

wp http get / --realm=admin --as=1

Scheme

--scheme=<http|https>

Force a particular scheme on the request URL., (*9)

Flags

--status
When set, only the HTTP status code and message are output. If the response is a 3xx, the location header is included as well., (*10)

--ssl-verify --no-ssl-verify
Whether or not SSL certificates should be checked against WordPress' bundled certificates. Good for working around self-signed certificates. Default: on, (*11)

Installation

Due to the nature of this command, it cannot be installed as a plugin and thus would not be useful to install as a project dependency. Instead, the HTTP Command is installed as a Composer package, and loaded by the local user's wp-cli config., (*12)

Create the wp-cli user directory, if it doesn't already exist, (*13)

mkdir ~/.wp-cli && cd ~/.wp-cli

Require the http command package, (*14)

composer require --prefer-dist aaemnnosttv/wp-cli-http-command:"^0.1"

Create the wp-cli config file, if it doesn't exist yet, (*15)

touch config.yml

Load composer. Edit the config.yml file and make sure vendor/autoload.php is being loaded under require like so, (*16)

require:
  - vendor/autoload.php

That's it! Now you should see the http command as an option when you run wp from any directory., (*17)

Inspiration

The Versions

20/10 2016

dev-master

9999999-dev

WP-CLI command for using the WordPress HTTP API

  Sources   Download

The Requires

  • php ^5.5 | ^7.0

 

20/08 2016

dev-develop

dev-develop

WP-CLI command for using the WordPress HTTP API

  Sources   Download

MIT

The Requires

  • php ^5.5 | ^7.0

 

The Development Requires