Coder Social home page Coder Social logo

estimates's Introduction

Wordpress XML-RPC PHP Client

Build Status Latest Stable Version Total Downloads Latest Unstable Version License

A PHP client for Wordpress websites that closely implement the XML-RPC WordPress API

Created by Hieu Le

MIT licensed.

Current version: 2.2.1

Features

  • Full test suit built in supporting testing using your own Wordpress site.
  • Support error logging to files with Monolog library.
  • 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,

Installation

You will need Composer installed on your machine to use this library. Verify that composer is installed by typing this command

composer --version

Choose one of the following methods to install Wordpress XML-RPC PHP Client

Your project has used composer:

Add this dependency into your composer.json file

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

After that, run composer update to install this package.

Your project does not use composer:

Clone or download the archive of this package from github. Copy the package directory into a location of your project. Open the command line terminal and do these command

cd library/installed/dir
composer install

After the installation progress finished, there will be a file called autoload.php created inside the vendor sub folder of the library. You should include this file to use Wordpress XML-RPC PHP Client.

Usage

All API call will be executed via an instance of the WordpressClient class. This is the way we initiate it:

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

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

# Save logs into file
$wpLog->useFiles('path-to-your-log-file');

# Create client instance
# The logger instance is optional
$wpClient = new \HieuLe\WordpressXmlrpcClient\WordpressClient($endpoint, 'username', 'password', $wpLog);

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

There will be 2 types of exception may be thrown from this library:

  • 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

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:

  • 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.

estimates's People

Contributors

kmorgan724 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.