Link to home
Start Free TrialLog in
Avatar of jdav357
jdav357

asked on

Wordpress API - add new page through Code igniter XML-RPC

Hi I am trying to write an application to allow me to update my wordpress blog through codeigniter's XML RPC.
[code]
This is the code for adding the new page in my class:
class wordpress extends CI_xmlrpc{ 
...code for username etc.. 
function newPage($content){
		$this->method('wp.newPage');
		$request = array($this->blog_id, $this->username, $this->password, $content);
		$this->request($request); 
		if ( ! $this->send_request()){
			return $this->display_error();
		}
		else{
			return $this->display_response(); 
		}
	}
} 
This is the code for getting the data from the user: 
form_open('media/wordpressAdd','id="wordpressForm"').
                                 form_input('post[title]').
                                 form_textarea('post[description]').
                                 form_hidden('post[publish]','1').
                                 form_submit('publish', 'Publish').
                                 form_close(); 

This is the snippet of code for putting the posted data into the above function: 
if($this->input->post('post')){
            $worked=$this->wordpress->newPage($this->input->post('post'));
            print $worked;
            $page['page']['heading']="Page Published";
            $page['page']['content']="";
        } 

The response I get from Wordpress is:
Invalid post type.  
I suspect it is something to do with using the array got from the post and passing that in to wordpress (http://codex.wordpress.org/XML-RPC_wp#Parameters_16):

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of gwkg
gwkg
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of jdav357
jdav357

ASKER

Thanks, the method calling is fine, but I suspect the format of the data which I am trying to send across to WP is not correct. I suspect that I am trying to send an associative array to WP via CI's xml-rpc, where it is expecting a struct.
Avatar of jdav357

ASKER

Thanks.