Giter Club home page Giter Club logo

rubypress's Introduction

rubypress

Gem Version

Build Status

This implements the WordPress XML RPC API as released in version 3.4.

WARNING: SSL is NOT enabled by default for ease of testing for those running OS X systems without setup SSL certs. If this is important to you, checkout the options for instantiating a new client where you can set :use_ssl to true.

Getting Started

  1. Install the gem

    A. To your system

    gem install rubypress

    B. Or using Bundler

    Inside your Gemfile:

    gem 'rubypress'

  2. Create a new client

    > wp = Rubypress::Client.new(:host => "yourwordpresssite.com", :username => "[email protected]", :password => "yourwordpresspassword")
  3. Make requests based off of the WordPress XML RPC API Documentation

    > wp.getOptions
    
    => {"software_name"=>{"desc"=>"Software Name", "readonly"=>true, "value"=>"WordPress"}

    (just a small excerpt of actual options for the sake of the whole brevity thing)

    > wp.newPost(:blog_id => "your_blog_id", :content => { :post_status => "publish", :post_date => Time.now, :post_content => "What an awesome post", :post_title => "Woo Title" })  
    => "24"  

    (returns a post ID if post was successful)

  4. Automatically retry timeouts

    When creating the client, you can optionally pass :retry_timeouts => true to rescue Timeout::Error and Net::ReadTimeout errors and retry the call.

To make further requests, check out the documentation - this gem should follow the exact format of the WordPress XML RPC API. For even further clarification on what requests are available, take a look in the spec folder.

NOTE: If your xmlrpc.php is not on the host root directory, you need to specify it's path. For example, to connect to myhostedwordpresssite.net/path/to/blog:

wp = Rubypress::Client.new(:host => "myhostedwordpresssite.net",
                           :path => "/path/to/blog/xmlrpc.php",
                           :username => "[email protected]",
                           :password => "yourwordpresspassword")

Contributing to rubypress

Pull requests welcome.

  • Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet.
  • Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it.
  • Fork the project.
  • Start a feature/bugfix branch.
  • Commit and push until you are happy with your contribution.
  • Make sure to add tests for it. This is important so we don't break it in a future version unintentionally.
  • Submit a pull request

Environment Variables

The test suite requires that the following environment variables are set:

  • WORDPRESS_HOST
  • WORDPRESS_USERNAME
  • WORDPRESS_PASSWORD

Optionally, you can create a file in the working directory called .env and add the following to it:

WORDPRESS_HOST=myhostedwordpresssite.net
[email protected]
WORDPRESS_PASSWORD=yourwordpresspassword

or use the sample-dot-env file as a base. .env will not be committed. When RSpec runs it will set the environment variables for you.

If you'd like to run the tests to test a server with plain HTTP authentication, use these environment vars:

WORDPRESS_HTTP_LOGIN=yourhttplogin
WORDPRESS_HTTP_PASS=yourhttppass
WORDPRESS_HTTP_USERNAME=yourwordpressusername
WORDPRESS_HTTP_PASSWORD=yourwordpresspassword
WORDPRESS_HTTP_HOST=yourhost.com
WORDPRESS_HTTP_PATH=/path/to/xmlrpc.php

Credits

  • Zach Feldman @zachfeldman - current maintainer, majority of codebase
  • Dan Collis-Puro @djcp - original project creator

Contributors

  • Abdelkader Boudih @seuros (Removed deep_merge monkeypatch if ActiveSupport is defined, small refactors, fixed dependency issue with retry)
  • Alex Dantas @alexdantas (README edits re: host option)
  • Pacop @pacop (Added a far easier way to upload files than the default method chain.)
  • David Muto @pseudomuto (Added ability to use a .env file and to retry failed requests)
  • Teemu Pääkkönen @borc (Added HTTP authentication and tests for it)

License

Licensed under the same terms as WordPress itself - GPLv2.

rubypress's People

Contributors

zachfeldman avatar seuros avatar pseudomuto avatar borc avatar rinkudas avatar alexdantas avatar bf4 avatar kieranp avatar

Watchers

James Cloos avatar  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.