2017 © Pedro Peláez
 

library wp-api-connect

image

zao-web/wp-api-connect

  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 15 Forks
  • 0 Open issues
  • 15 Versions
  • 0 % Grown

The README.md

WP API Connect (0.2.6)

A tool for connecting to the REST API for WordPress via OAuth 1.0a., (*1)

To get started, you'll need to install both the WP REST API plugin and the OAuth plugin., (*2)

To use this library, you will need to run composer install from the root of the library, and then include the main library file, wp-api-connect.php and the composer autoloader, vendor/autoload.php from your plugin/theme., (*3)

(Hint: If you would like to have a UI for saving client keys and testing the connection, Check out the WP API Connect UI.), (*4)

Once installed and activated, you'll need to create a 'Client Application'. When you have the Client key and secret, you'll create a new Zao\WP_API\OAuth1\Connect object by passing those credentials along with the REST API URL and the registered callback URL:, (*5)

// Make sure you run `composer install`!
require_once 'vendor/autoload.php';

// include the library.
require_once( 'wp-api-connect.php' );

// Get the connect object
$api_connect = new Zao\WP_API\OAuth1\Connect();

// Client credentials
$client = array(

    // Library will 'discover' the API url
    'api_url' => 'WP SITE URL TO CONNECT TO',

    // App credentials set up on the server
    'client_key' => 'YOUR CLIENT KEY',
    'client_secret' => 'YOUR CLIENT SECRET',

    // Must match stored callback URL setup on server.
    'callback_uri' => admin_url() . '?api-connect',
);

/*
 * Initate the API connection.
 *
 * if the oauth connection is not yet authorized, (and autoredirect_authoriziation
 * is not explicitly set to false) you will be auto-redirected to the other site to
 * receive authorization.
 */
$discovery = $api_connect->init( $client );

You can then use this object to retrieve the authentication request URL, or if you have been authenticated, make requests. To see a full example, view the included example.php file., (*6)

Changelog

0.2.6

  • Remove Ryan McCue's Requests library from composer since it now exists in WP core.
  • Rename.

0.2.5

  • Fix a typo from a variable which should be using an object property (for legacy mode).

0.2.4

  • Fix broken logic in Connect::auth_request() where $response variable might not get properly set.

0.2.3

  • Update example.php
  • Make requests more consistent, and pass parameters through appropriate filters.
  • Fixed a few missed exception handlers.

0.2.2

  • Add set_headers method to be able to set headers for discovery.
  • Use our own API Discovery library to use the WP http API, and to correctly pass any headers if they exist.

0.2.1

  • Bug fix: Fix the order of checks in the reset_connection method to ensure the delete_stored_error method is always called.

0.2.0

0.1.5

  • Remove autoload from composer.json (for now).

0.1.4

  • Add utility methods for dealing with errors.
  • Convert post body to a query string before wp_remote_request does because http_build_query drops empty values and oauth signatures end up not matching.

0.1.3

  • Fix some docs, and "clever" code, and fix an incorrect variable name.
  • Add class_exists check so we don't break sites w/ multiple instantiations.
  • Store response code as object property.
  • Account for WP_Error from responses before creating response code.
  • Accept a headers array, and pass those headers to all requests.
  • Option/transient key should be a hash of all the args, not just the url.
  • Do not cache api description if request is a failure (or being requested not to).
  • Make headers and key/option_key accessible as read-only properties.
  • Change from JSON to REST to match WordPress core plugin.
  • Move error option to its own method.

0.1.2

  • Better checks for failed requests.
  • Set the http method for each call so that the OAuth signature matches.
  • Create a redirect URL based on current url or allow one to be passed in.
  • Keep response as an accessible class property, and add get/set request methods. Also properly handle GET request authorization header.
  • Some cleanup based on scrutinizer feedback.

0.1.1

  • Rename file

0.1.0

  • Release

The Versions

07/03 2018

v0.1.0

0.1.0.0

  Sources   Download

07/03 2018

v0.1.1

0.1.1.0

  Sources   Download

25/08 2017

dev-master

9999999-dev https://github.com/zao-web/wp-api-connect

Helper class for connecting from one WordPress installation to another via the WordPress REST API and OAuth.

  Sources   Download

GPL-2.0+

The Requires

 

wordpress json wp-api

09/03 2017

v0.2.6

0.2.6.0 https://github.com/zao-web/wp-api-connect

Helper class for connecting from one WordPress installation to another via the WordPress REST API and OAuth.

  Sources   Download

GPL-2.0+

The Requires

 

wordpress json wp-api

17/03 2016

v0.2.5

0.2.5.0 https://github.com/WebDevStudios/WDS-WP-REST-API-Connect

Helper class for connecting from one WordPress installation to another via the WordPress REST API and OAuth.

  Sources   Download

GPL-2.0+

The Requires

 

wordpress json wp-api

17/03 2016

v0.2.4

0.2.4.0 https://github.com/WebDevStudios/WDS-WP-REST-API-Connect

Helper class for connecting from one WordPress installation to another via the WordPress REST API and OAuth.

  Sources   Download

GPL-2.0+

The Requires

 

wordpress json wp-api

18/02 2016

v0.2.3

0.2.3.0 https://github.com/WebDevStudios/WDS-WP-REST-API-Connect

Helper class for connecting from one WordPress installation to another via the WordPress REST API and OAuth.

  Sources   Download

GPL-2.0+

The Requires

 

wordpress json wp-api

16/02 2016

v0.2.2

0.2.2.0 https://github.com/WebDevStudios/WDS-WP-REST-API-Connect

Helper class for connecting from one WordPress installation to another via the WordPress REST API and OAuth.

  Sources   Download

GPL-2.0+

The Requires

 

wordpress json wp-api

15/02 2016

v0.2.1

0.2.1.0 https://github.com/WebDevStudios/WDS-WP-REST-API-Connect

Helper class for connecting from one WordPress installation to another via the WordPress REST API and OAuth.

  Sources   Download

GPL-2.0+

The Requires

 

wordpress json wp-api

15/02 2016

v0.2.0

0.2.0.0 https://github.com/WebDevStudios/WDS-WP-REST-API-Connect

Helper class for connecting from one WordPress installation to another via the WordPress REST API and OAuth.

  Sources   Download

GPL-2.0+

The Requires

 

wordpress json wp-api

06/02 2016

v0.1.5

0.1.5.0 https://github.com/WebDevStudios/WDS-WP-REST-API-Connect

Helper class for connecting from one WordPress installation to another via the WordPress REST API and OAuth.

  Sources   Download

GPL-2.0+

The Requires

  • php >5.3

 

wordpress json wp-api

20/11 2015

v0.1.4

0.1.4.0 https://github.com/WebDevStudios/WDS-WP-REST-API-Connect

Helper class for connecting from one WordPress installation to another via the WordPress REST API and OAuth.

  Sources   Download

GPL-2.0+

The Requires

  • php >5.3

 

wordpress json wp-api

20/11 2015

dev-bug/circumvent-httpbuildquery

dev-bug/circumvent-httpbuildquery https://github.com/WebDevStudios/WDS-WP-JSON-API-Connect2

Helper class for connecting from one WordPress installation to another via the WordPress JSON API and OAuth.

  Sources   Download

GPL-2.0+

The Requires

  • php >5.3

 

wordpress json wp-api

23/10 2015

v0.1.3

0.1.3.0 https://github.com/WebDevStudios/WDS-WP-REST-API-Connect

Helper class for connecting from one WordPress installation to another via the WordPress REST API and OAuth.

  Sources   Download

GPL-2.0+

The Requires

  • php >5.3

 

wordpress json wp-api

22/12 2014

v0.1.2

0.1.2.0 https://github.com/WebDevStudios/WDS-WP-JSON-API-Connect2

Helper class for connecting from one WordPress installation to another via the WordPress JSON API and OAuth.

  Sources   Download

GPL-2.0+

The Requires

  • php >5.3

 

wordpress json wp-api