class MetaWeblog (View source)

MetaWeblog client

Properties

protected $user Username
protected $pass Password
protected $encoding Messages encoding (will be applied to - almost - every string!)

Methods

__construct(string $address, string $user = false, string $pass = false)

Class constructor

setId(int $id)

Set the blog id

setEncoding(string $encoding)

Set encoding

int
getId()

Get blog id

string
getEncoding()

Get current encoding

RpcClient
getRpcClient()

Get the RPC client object

array
getPost(int $id)

Retrieve a post from weblog

array
getRecentPosts(int $howmany = 10)

Get [$howmany] posts from blog

int
newPost($struct, $publish = true)

Create new post using xmlrpc

int
editPost($postId, $struct, $publish = true)

Edit post using remote server xmlrpc interface, referenced by postId

bool
deletePost(int $postId, int $appkey = false, int $publish = false)

Delete a post referenced by postId

array
getCategories()

Retrieve a list of categories from weblog

bool
newMediaObject(string $name, string $mimetype, mixed $content, int $overwrite = false)

upload a new media to weblog using metaWeblog.newMediaObject call

array
getTemplate(string $template_type, string $appkey = false)

get template

bool
setTemplate(string $template, string $template_type, string $appkey = false)

get template

array
getUsersBlogs(int $appkey = false)

Returns information about all the blogs a given user is a member of

mixed
sendRpcRequest(string $method, array $params)

Send the request via RpcClient

static mixed
sanitizeText(mixed $mixed, string $encoding)

Re-encode text

Details

__construct(string $address, string $user = false, string $pass = false)

Class constructor

Parameters

string $address RPC server full address
string $user (optional) Username
string $pass (optional) Password

Exceptions

MetaWeblogException
HttpException;
Exception;

final MetaWeblog setId(int $id)

Set the blog id

Parameters

int $id Blog ID

Return Value

MetaWeblog

final MetaWeblog setEncoding(string $encoding)

Set encoding

Parameters

string $encoding

Return Value

MetaWeblog

final int getId()

Get blog id

Return Value

int

final string getEncoding()

Get current encoding

Return Value

string

final RpcClient getRpcClient()

Get the RPC client object

Return Value

RpcClient

array getPost(int $id)

Retrieve a post from weblog

Parameters

int $id Post's ID

Return Value

array

Exceptions

MetaWeblogException
RpcException
HttpException
XmlrpcException
Exception

array getRecentPosts(int $howmany = 10)

Get [$howmany] posts from blog

Parameters

int $howmany Number of posts to retrieve from blog (default 10)

Return Value

array Posts from blog

Exceptions

RpcException
HttpException
XmlrpcException
Exception

int newPost($struct, $publish = true)

Create new post using xmlrpc

Minimum $struct elements to compose new post are: - title string the post title - description string the post content

If one or both not defined, method will throw an "Invalid post struct" error.

Parameters

$struct
$publish

Return Value

int

Exceptions

MetaWeblogException
RpcException
HttpException
XmlrpcException
Exception

int editPost($postId, $struct, $publish = true)

Edit post using remote server xmlrpc interface, referenced by postId

Parameters

$postId
$struct
$publish

Return Value

int Assigned post ID

Exceptions

MetaWeblogException
RpcException
HttpException
XmlrpcException
Exception

bool deletePost(int $postId, int $appkey = false, int $publish = false)

Delete a post referenced by postId

Parameters

int $postId
int $appkey
int $publish

Return Value

bool

Exceptions

MetaWeblogException
RpcException
HttpException
XmlrpcException
Exception

array getCategories()

Retrieve a list of categories from weblog

Return Value

array Categories

Exceptions

RpcException
HttpException
XmlrpcException
Exception

bool newMediaObject(string $name, string $mimetype, mixed $content, int $overwrite = false)

upload a new media to weblog using metaWeblog.newMediaObject call

Parameters

string $name
string $mimetype
mixed $content
int $overwrite

Return Value

bool

Exceptions

MetaWeblogException
RpcException
HttpException
XmlrpcException
Exception

array getTemplate(string $template_type, string $appkey = false)

get template

Parameters

string $template_type
string $appkey

Return Value

array

Exceptions

MetaWeblogException
RpcException
HttpException
XmlrpcException
Exception

bool setTemplate(string $template, string $template_type, string $appkey = false)

get template

Parameters

string $template
string $template_type
string $appkey

Return Value

bool

Exceptions

MetaWeblogException
RpcException
HttpException
XmlrpcException
Exception

array getUsersBlogs(int $appkey = false)

Returns information about all the blogs a given user is a member of

Parameters

int $appkey

Return Value

array Posts from blog

Exceptions

RpcException
HttpException
XmlrpcException
Exception

protected mixed sendRpcRequest(string $method, array $params)

Send the request via RpcClient

Parameters

string $method
array $params

Return Value

mixed

Exceptions

RpcException
HttpException
XmlrpcException
Exception

static protected mixed sanitizeText(mixed $mixed, string $encoding)

Re-encode text

Parameters

mixed $mixed
string $encoding

Return Value

mixed