2017 © Pedro Peláez
 

library wordpress-xmlrpc-client

A PHP client for Wordpress websites that closely implement the XML-RPC WordPress API with full test suite built in

image

hieu-le/wordpress-xmlrpc-client

A PHP client for Wordpress websites that closely implement the XML-RPC WordPress API with full test suite built in

  • Thursday, February 4, 2016
  • by letrunghieu
  • Repository
  • 15 Watchers
  • 90 Stars
  • 36,776 Installations
  • PHP
  • 5 Dependents
  • 0 Suggesters
  • 40 Forks
  • 9 Open issues
  • 13 Versions
  • 7 % Grown

The README.md

Wordpress XML-RPC PHP Client

Build Status Latest Stable Version Total Downloads Latest Unstable Version License, (*1)

A PHP client for Wordpress websites that closely implement the XML-RPC WordPress API, (*2)

Created by Hieu Le, (*3)

MIT licensed., (*4)

Current version: 2.4.2, (*5)

All Important Features

  • Full test suit built in supporting testing using your own Wordpress site.
  • ~~Support error logging to files with Monolog library.~~ Now, erros can be logged in a more felxible way via error callbacks (v 2.4.0)
  • Support UTF-8 content.
  • Closely implement the whole XML-RPC WordPress API.
  • Detail exception will be thrown when errors occurs.
  • (v2.2) Support proxy and http authentication.
  • (v2.2.1) Allow value of DateTime class to be convert correctly to datetime.iso8601 XML-RPC type,
  • (v2.4.0) Support using custom User Agent string beside the default User Agent string.
  • (v2.4.0) Support callbacks on sending and error events

Installation

~~You will need Composer installed on your machine to use this library~~ Composer now is not required but recommended. Verify that composer is installed by typing this command, (*6)

composer --version

Choose one of the following methods to install Wordpress XML-RPC PHP Client, (*7)

Your project has used composer:

Add this dependency into your composer.json file, (*8)

"hieu-le/wordpress-xmlrpc-client":"~2.0"

After that, run composer update to install this package., (*9)

Your project does not use composer:

Clone or download the archive of this package from github. Include all files in the src directory into your project and start using Wordpress XML-RPC Client. You have to update the code of this library manually if using it without Composer., (*10)

Required PHP extension is xmlrpc extension. The curl extension is optional but recommended., (*11)

Usage

All API call will be executed via an instance of the WordpressClient class. Since version 2.4.0, there is no mandatory parameters in the contructor. endPoint, username, and password can be updated anytime by calling setCredentials method. The last parameter in previous version contructor (which is an instance of \Illuminate\Log\Writer class) is deprecated and will be removed in the next major release. Below is an example of using this library:, (*12)

# Your Wordpress website is at: http://wp-website.com
$endpoint = "http://wp-website.com/xmlrpc.php";

# The Monolog logger instance
$wpLog = new Monolog\Logger('wp-xmlrpc');

# Create client instance
$wpClient = new \HieuLe\WordpressXmlrpcClient\WordpressClient();
# Log error
$wpClient->onError(function($error, $event) use ($wpLog){
    $wpLog->addError($error, $event);
});

# Set the credentials for the next requests
$wpClient->setCredentials($endpoint, 'username', 'password');

If you have used logging feture of previous version of this library, you should update your code to use the new way of loggin as above, the Monolog instance can be replaced by any kinds of logging tool that you have., (*13)

To use date time value, you must use an instance of DateTime class instead of a string., (*14)

There will be 2 types of exception may be thrown from this library:, (*15)

  • XmlrpcException: this kind of exception will be thrown if there is an error when the server executing your request
  • NetworkException: this kind of exception will be thrown if there is an error when transfer your request to server or when getting the response.

For API reference, visit Wordpress documentation or Library API documentation, (*16)

User Agent (since 2.4.0)

The library use the default User Agent when contacting with Wordpress blogs. If you want to use onother one, pass your custom User Agent string into the setUserAgent method. If you passed a falsy value (null, false, ...) the default one will be used (thank @WarrenMoore), (*17)

Callbacks and events (since 2.4.0)

The library allow developers to listen on two events Sending and Error. You can add new closure as a callback for each events by calling on<event> method with the closure as parameter (see the onError example above)., (*18)

onSending($event)

This event is fired before each request is send to Wordpress blogs. $event is an array:, (*19)

  • event: the name of the event, here is sending
  • endpoint: URL of the current endpoint
  • username: current username
  • password: current password
  • method: current XML-RPC method
  • params: parameters passed to the current method
  • request: the body of the current request which will be sent
  • proxy: current proxy config
  • auth: current http auth config

onError($errorMessage, $event)

This event is fired when the library run into errors, before any exception thrown. $errorMessage is a string. $event is an array:, (*20)

  • event: the name of the event, here is sending
  • endpoint: URL of the current endpoint
  • request: the body of the current request
  • proxy: current proxy config
  • auth: current http auth config

Unit testing

By default, the project use recorded data as the default data for test suite. However, if you want to test with your own Wordpress installation, there are available options inside the ./tests/xmlrpc.yml file:, (*21)

  • endpoint: the url of your Wordpress XML-RPC endpoint
  • admin_login: the email or username of a user with the Administrator role
  • admin_password: the password of the admin user
  • guest_login: the email or username of a user with the Subscriber role
  • guest_password: the password of the guest user

After update the ./tests/xmlrpc.yml file, run your test again., (*22)

The Versions

04/02 2016

dev-master

9999999-dev

A PHP client for Wordpress websites that closely implement the XML-RPC WordPress API with full test suite built in

  Sources   Download

MIT

The Requires

  • php >=5.3.0
  • ext-xmlrpc *

 

The Development Requires

wordpress api client remote xmlrpc

04/02 2016

2.5.0

2.5.0.0

A PHP client for Wordpress websites that closely implement the XML-RPC WordPress API with full test suite built in

  Sources   Download

MIT

The Requires

  • php >=5.3.0
  • ext-xmlrpc *

 

The Development Requires

wordpress api client remote xmlrpc

05/10 2015

2.4.3

2.4.3.0

A PHP client for Wordpress websites that closely implement the XML-RPC WordPress API with full test suite built in

  Sources   Download

MIT

The Requires

  • php >=5.3.0
  • ext-xmlrpc *

 

The Development Requires

wordpress api client remote xmlrpc

29/05 2015

2.4.2

2.4.2.0

A PHP client for Wordpress websites that closely implement the XML-RPC WordPress API with full test suite built in

  Sources   Download

MIT

The Requires

  • php >=5.3.0
  • ext-xmlrpc *

 

The Development Requires

wordpress api client remote xmlrpc

19/03 2015

2.4.1

2.4.1.0

A PHP client for Wordpress websites that closely implement the XML-RPC WordPress API with full test suite built in

  Sources   Download

MIT

The Requires

  • php >=5.3.0
  • ext-xmlrpc *

 

The Development Requires

wordpress api client remote xmlrpc

25/08 2014

2.4.0

2.4.0.0

A PHP client for Wordpress websites that closely implement the XML-RPC WordPress API with full test suite built in

  Sources   Download

MIT

The Requires

  • php >=5.3.0
  • ext-xmlrpc *

 

The Development Requires

wordpress api client remote xmlrpc

21/08 2014

2.3.1

2.3.1.0

A PHP client for Wordpress websites that closely implement the XML-RPC WordPress API with full test suite built in

  Sources   Download

MIT

The Requires

 

The Development Requires

wordpress api client remote xmlrpc

20/06 2014

2.3

2.3.0.0

A PHP client for Wordpress websites that closely implement the XML-RPC WordPress API with full test suite built in

  Sources   Download

MIT

The Requires

 

The Development Requires

wordpress api client remote xmlrpc

20/06 2014

2.2.1

2.2.1.0

A PHP client for Wordpress websites that closely implement the XML-RPC WordPress API with full test suite built in

  Sources   Download

MIT

The Requires

 

The Development Requires

wordpress api client remote xmlrpc

15/05 2014

2.2

2.2.0.0

A PHP client for Wordpress websites that closely implement the XML-RPC WordPress API with full test suite built in

  Sources   Download

MIT

The Requires

 

The Development Requires

wordpress api client remote xmlrpc

09/05 2014

2.1

2.1.0.0

A PHP client for Wordpress websites that closely implement the XML-RPC WordPress API with full test suite built in

  Sources   Download

MIT

The Requires

 

The Development Requires

wordpress api client remote xmlrpc

18/04 2014

2.0

2.0.0.0

A PHP client for Wordpress websites that closely implement the XML-RPC WordPress API with full test suite built in

  Sources   Download

MIT

The Requires

 

The Development Requires

wordpress api client remote xmlrpc

14/03 2014

1.0

1.0.0.0

A simple XMLRPC client to work with Wordpress websites

  Sources   Download

MIT

The Requires

 

wordpress client remote xmlrpc