wordpress-client

Gem Version Build Status

wordpress-client is a Wordpress Rest API Wrapper.

Requirements

I test with ruby 1.9.3 and 2.1.0. Other versions/VMs are untested but might work fine.

Installation

To your system

gem install wordpress-client

Or add wordpress-client to your Gemfile and bundle install:

gem 'wordpress-client'

Usage

Create new client

require 'wordpress-client'

# Shared client
client = Wordpress.client

# New client
client = Wordpress::Client.new

Call API without access token

# Get posts of a specific domain without access token
posts = client.get_posts('wordpress-site-domain')
posts.each do |post|
  # Do something
end

# Get all the posts of a specific domain without access token
page = 1
loop do
  posts = client.get_posts('wordpress-site-domain', :page => page)
  posts.each do |post|
    # Do something
  end
  break if posts.size == 0
  page += 1
end

Call API with access token

# Get user by access token
client.access_token = 'YOUR_ACCESS_TOKEN' # if you have any
user = client.me
site = user.site
posts = site.posts

TODO

  • Support create/update/delete from Wordpress::Object
  • Add oauth method

Contributing

See the contributing guide.

Copyright (c) 2013-2013 Daisuke Taniwaki. See LICENSE for details.