Wordpress XML-RPC PHP Client
  • Namespace
  • Class

Namespaces

  • HieuLe
    • WordpressXmlrpcClient
      • Exception

Classes

  • WordpressClient

Class WordpressClient

A XML-RPC client that implement the Wordpress API.

Namespace: HieuLe\WordpressXmlrpcClient
License: MIT
Author: Hieu Le http://www.hieule.info
Version: 2.5.0
Located at WordpressClient.php

Methods summary

public
# __construct( string $xmlrpcEndPoint = null, string $username = null, string $password = null, Illuminate\Log\Writer $logger = null )

Create a new client

Create a new client

Parameters

$xmlrpcEndPoint
The wordpress XML-RPC endpoint (optional)
$username
The client's username (optional)
$password
The client's password (optional)
$logger
deprecated. This variable will not be used since 2.4.0
public
# onError( Closure $callback )

Add a callback for error event

Add a callback for error event

Parameters

$callback

Since

2.4.0
public
# onSending( Closure $callback )

Add a callback for sending event

Add a callback for sending event

Parameters

$callback

Since

2.4.0
public
# setCredentials( string $xmlrpcEndPoint, string $username, string $password )

Set the endpoint, username and password for next requests

Set the endpoint, username and password for next requests

Parameters

$xmlrpcEndPoint
The wordpress XML-RPC endpoint
$username
The client's username
$password
The client's password

Since

2.4.0
public string
# getEndPoint( )

Get the current endpoint URL

Get the current endpoint URL

Returns

string

Since

2.4.2
public string
# getDefaultUserAgent( )

Get library default user agent

Get library default user agent

Returns

string

Since

2.4.0
public string
# getUserAgent( )

Get current user agent string

Get current user agent string

Returns

string

Since

2.4.0
public
# setUserAgent( string $userAgent )

Set the user agent for next requests

Set the user agent for next requests

Parameters

$userAgent
custom user agent, give a falsy value to use library user agent

Since

2.4.0
public string
# getErrorMessage( )

Get the latest error message

Get the latest error message

Returns

string

Since

2.2
public
# setProxy( boolean|array $proxyConfig )

Set the proxy config. To disable proxy, using

false

as parameter

Set the proxy config. To disable proxy, using

false

as parameter

Parameters

$proxyConfig

The configuration array has these fields:

  • proxy_ip
    : the ip of the proxy server (WITHOUT port)
  • proxy_port
    : the port of the proxy server
  • proxy_user
    : the username for proxy authorization
  • proxy_pass
    : the password for proxy authorization
  • proxy_mode
    : value for CURLOPT_PROXYAUTH option (default to CURLAUTH_BASIC)

Throws

InvalidArgumentException

Since

2.2

See

curl_setopt
public boolean|array
# getProxy( )

Get current proxy config

Get current proxy config

Returns

boolean|array

Since

2.2
public
# setAuth( boolean|array $authConfig )

Set authentication info

Set authentication info

Parameters

$authConfig

the configuation array

  • auth_user
    : the username for server authentication
  • auth_pass
    : the password for server authentication
  • auth_mode
    : value for CURLOPT_HTTPAUTH option (default to CURLAUTH_BASIC)

Throws

InvalidArgumentException

Since

2.2

See

curl_setopt
public type
# getAuth( )

Get the current HTTP authentication config

Get the current HTTP authentication config

Returns

type

Since

2.2
public array
# getPost( integer $postId, array $fields = array() )

Retrieve a post of any registered post type.

Retrieve a post of any registered post type.

Parameters

$postId
the id of selected post
$fields
(optional) list of field or meta-field names to include in response.

Returns

array

Link

http://codex.wordpress.org/XML-RPC_WordPress_API/Posts#wp.getPosts
public array
# getPosts( array $filters = array(), array $fields = array() )

Retrieve list of posts of any registered post type.

Retrieve list of posts of any registered post type.

Parameters

$filters
optional
$fields
optional

Returns

array
array of struct

Link

http://codex.wordpress.org/XML-RPC_WordPress_API/Posts#wp.getPosts
public integer
# newPost( string $title, string $body, array $content = array(), integer $thumbnailId,…, array $content,… )

Create a new post of any registered post type.

Create a new post of any registered post type.

Parameters

$title
the post title
$body
the post body
$content
$categorieIds the list of category ids
$thumbnailId,…
the thumbnail id
$content,…
the content array, see more at wordpress documentation

Returns

integer
the new post id

Link

http://codex.wordpress.org/XML-RPC_WordPress_API/Posts#wp.newPost
public boolean
# editPost( integer $postId, array $content, string $body,…, array $categorieIds,…, integer $thumbnailId,…, array $content,… )

Edit an existing post of any registered post type.

Edit an existing post of any registered post type.

Parameters

$postId
the id of selected post
$content
$title the new title
$body,…
the new body
$categorieIds,…
the new list of category ids
$thumbnailId,…
the new thumbnail id
$content,…
the advanced array

Returns

boolean

Link

http://codex.wordpress.org/XML-RPC_WordPress_API/Posts#wp.editPost
public boolean
# deletePost( integer $postId )

Delete an existing post of any registered post type.

Delete an existing post of any registered post type.

Parameters

$postId
the id of selected post

Returns

boolean

Link

http://codex.wordpress.org/XML-RPC_WordPress_API/Posts#wp.deletePost
public array
# getPostType( string $postTypeName, array $fields = array() )

Retrieve a registered post type.

Retrieve a registered post type.

Parameters

$postTypeName
the post type name
$fields
(optional) list of field or meta-field names to include in response.

Returns

array

Link

http://codex.wordpress.org/XML-RPC_WordPress_API/Posts#wp.getPostType
public array
# getPostTypes( array $filter = array(), array $fields = array() )

Retrieve list of registered post types.

Retrieve list of registered post types.

Parameters

$filter
$fields

Returns

array
list of struct

Link

http://codex.wordpress.org/XML-RPC_WordPress_API/Posts#wp.getPostTypes
public array
# getPostFormats( )

Retrieve list of post formats.

Retrieve list of post formats.

Returns

array

Link

http://codex.wordpress.org/XML-RPC_WordPress_API/Posts#wp.getPostFormats
public array
# getPostStatusList( )

Retrieve list of supported values for post_status field on posts.

Retrieve list of supported values for post_status field on posts.

Returns

array
list of supported post status

Link

http://codex.wordpress.org/XML-RPC_WordPress_API/Posts#wp.getPostStatusList
public array
# getTaxonomy( string $taxonomy )

Retrieve information about a taxonomy.

Retrieve information about a taxonomy.

Parameters

$taxonomy
the name of the selected taxonomy

Returns

array
taxonomy information

Link

http://codex.wordpress.org/XML-RPC_WordPress_API/Taxonomies#wp.getTaxonomy
public array
# getTaxonomies( )

Retrieve a list of taxonomies.

Retrieve a list of taxonomies.

Returns

array
array of taxonomy struct

Link

http://codex.wordpress.org/XML-RPC_WordPress_API/Taxonomies#wp.getTaxonomies
public array
# getTerm( integer $termId, string $taxonomy )

Retrieve a taxonomy term.

Retrieve a taxonomy term.

Parameters

$termId
$taxonomy

Returns

array

Link

http://codex.wordpress.org/XML-RPC_WordPress_API/Taxonomies#wp.getTerm
public array
# getTerms( string $taxonomy, array $filter = array() )

Retrieve list of terms in a taxonomy.

Retrieve list of terms in a taxonomy.

Parameters

$taxonomy
$filter

Returns

array

Link

http://codex.wordpress.org/XML-RPC_WordPress_API/Taxonomies#wp.getTerms
public integer
# newTerm( string $name, string $taxomony, string $slug = null, string $description = null, integer $parentId = null )

Create a new taxonomy term.

Create a new taxonomy term.

Parameters

$name
$taxomony
$slug
$description
$parentId

Returns

integer
new term id

Link

http://codex.wordpress.org/XML-RPC_WordPress_API/Taxonomies#wp.newTerm
public boolean
# editTerm( integer $termId, string $taxonomy, array $content = array() )

Edit an existing taxonomy term.

Edit an existing taxonomy term.

Parameters

$termId
$taxonomy
$content

Returns

boolean

Link

http://codex.wordpress.org/XML-RPC_WordPress_API/Taxonomies#wp.editTerm
public boolean
# deleteTerm( integer $termId, string $taxonomy )

Delete an existing taxonomy term.

Delete an existing taxonomy term.

Parameters

$termId
$taxonomy

Returns

boolean

Link

http://codex.wordpress.org/XML-RPC_WordPress_API/Taxonomies#wp.deleteTerm
public array
# getMediaItem( integer $itemId )

Retrieve a media item (i.e, attachment).

Retrieve a media item (i.e, attachment).

Parameters

$itemId

Returns

array

Link

http://codex.wordpress.org/XML-RPC_WordPress_API/Media#wp.getMediaItem
public array
# getMediaLibrary( array $filter = array() )

Retrieve list of media items.

Retrieve list of media items.

Parameters

$filter

Returns

array

Link

http://codex.wordpress.org/XML-RPC_WordPress_API/Media#wp.getMediaLibrary
public array
# uploadFile( string $name, string $mime, string $bits, boolean $overwrite = null, integer $postId = null )

Upload a media file.

Upload a media file.

Parameters

$name
file name
$mime
file mime type
$bits
binary data (no encoded)
$overwrite
(optional)
$postId
(optional)

Returns

array

Link

http://codex.wordpress.org/XML-RPC_WordPress_API/Media#wp.uploadFile
public integer
# getCommentCount( integer $postId )

Retrieve comment count for a specific post.

Retrieve comment count for a specific post.

Parameters

$postId

Returns

integer

Link

http://codex.wordpress.org/XML-RPC_WordPress_API/Comments#wp.getCommentCount
public array
# getComment( integer $commentId )

Retrieve a comment.

Retrieve a comment.

Parameters

$commentId

Returns

array

Link

http://codex.wordpress.org/XML-RPC_WordPress_API/Comments#wp.getComment
public array
# getComments( array $filter = array() )

Retrieve list of comments.

Retrieve list of comments.

Parameters

$filter

Returns

array

Link

http://codex.wordpress.org/XML-RPC_WordPress_API/Comments#wp.getComments
public integer
# newComment( integer $post_id, array $comment )

Create a new comment.

Create a new comment.

Parameters

$post_id
$comment

Returns

integer
new comment_id

Link

http://codex.wordpress.org/XML-RPC_WordPress_API/Comments#wp.newComment
public boolean
# editComment( integer $commentId, array $comment )

Edit an existing comment.

Edit an existing comment.

Parameters

$commentId
$comment

Returns

boolean

Link

http://codex.wordpress.org/XML-RPC_WordPress_API/Comments#wp.editComment
public boolean
# deleteComment( integer $commentId )

Remove an existing comment.

Remove an existing comment.

Parameters

$commentId

Returns

boolean

Link

http://codex.wordpress.org/XML-RPC_WordPress_API/Comments#wp.deleteComment
public array
# getCommentStatusList( )

Retrieve list of comment statuses.

Retrieve list of comment statuses.

Returns

array

Link

http://codex.wordpress.org/XML-RPC_WordPress_API/Comments#wp.getCommentStatusList
public array
# getOptions( array $options = array() )

Retrieve blog options.

Retrieve blog options.

Parameters

$options

Returns

array

Link

http://codex.wordpress.org/XML-RPC_WordPress_API/Options#wp.getOptions
public array
# setOptions( array $options )

Edit blog options.

Edit blog options.

Parameters

$options

Returns

array

Link

http://codex.wordpress.org/XML-RPC_WordPress_API/Options#wp.setOptions
public array
# getUsersBlogs( )

Retrieve list of blogs for this user.

Retrieve list of blogs for this user.

Returns

array

Link

http://codex.wordpress.org/XML-RPC_WordPress_API/Users#wp.getUsersBlogs
public array
# getUser( integer $userId, array $fields = array() )

Retrieve a user.

Retrieve a user.

Parameters

$userId
$fields
Optional. List of field or meta-field names to include in response.

Returns

array

Link

http://codex.wordpress.org/XML-RPC_WordPress_API/Users#wp.getUser
public array
# getUsers( array $filters = array(), array $fields = array() )

Retrieve list of users.

Retrieve list of users.

Parameters

$filters
$fields

Returns

array

Link

http://codex.wordpress.org/XML-RPC_WordPress_API/Users#wp.getUsers
public array
# getProfile( array $fields = array() )

Retrieve profile of the requesting user.

Retrieve profile of the requesting user.

Parameters

$fields

Returns

array

Link

http://codex.wordpress.org/XML-RPC_WordPress_API/Users#wp.getProfile
public boolean
# editProfile( array $content )

Edit profile of the requesting user.

Edit profile of the requesting user.

Parameters

$content

Returns

boolean
http://codex.wordpress.org/XML-RPC_WordPress_API/Users#wp.editProfile
public mixed
# callCustomMethod( string $method, array $params )

Call a custom XML-RPC method

Call a custom XML-RPC method

Parameters

$method
the method name
$params
the parameters of this call

Returns

mixed

Since

2.3.0
public string
# createXMLRPCDateTime( DateTime $datetime )

Create an XMLRPC DateTime object

Create an XMLRPC DateTime object

Parameters

$datetime

Returns

string
with the XMLRPC internal type is set to datetime
protected
# performRequest( )
protected
# getRequest( )
Wordpress XML-RPC PHP Client API documentation generated by ApiGen