publish new post from another website by xmlrpc
-
hi
i want to publish some new post from my another website to my wordpress.
i am looking for php script that call below function ,witch is placed on xmlrpc.php file on my wordpress//it try them on my local host
/* blogger.newPost ...creates a new post */ function blogger_newPost($args) { $this->escape($args); $blog_ID = (int) $args[1]; /* though we don't use it yet */ $user_login = $args[2]; $user_pass = $args[3]; $content = $args[4]; $publish = $args[5]; if (!$this->login_pass_ok($user_login, $user_pass)) { return $this->error; } do_action('xmlrpc_call', 'blogger.newPost'); $cap = ($publish) ? 'publish_posts' : 'edit_posts'; $user = set_current_user(0, $user_login); if ( !current_user_can($cap) ) return new IXR_Error(401, __('Sorry, you are not allowed to post on this blog.')); $post_status = ($publish) ? 'publish' : 'draft'; $post_author = $user->ID; $post_title = xmlrpc_getposttitle($content); $post_category = xmlrpc_getpostcategory($content); $post_content = xmlrpc_removepostdata($content); $post_date = current_time('mysql'); $post_date_gmt = current_time('mysql', 1); $post_data = compact('blog_ID', 'post_author', 'post_date', 'post_date_gmt', 'post_content', 'post_title', 'post_category', 'post_status'); $post_ID = wp_insert_post($post_data); if ( is_wp_error( $post_ID ) ) return new IXR_Error(500, $post_ID->get_error_message()); if (!$post_ID) return new IXR_Error(500, __('Sorry, your entry could not be posted. Something wrong happened.')); $this->attach_uploads( $post_ID, $post_content ); logIO('O', "Posted ! ID: $post_ID"); return $post_ID; }
i have use the below script to call it:
<html> <head> <title>XML-RPC PHP Demo</title> </head> <body> <h1>XML-RPC PHP Demo</h1> <?php include 'xmlrpc.inc'; // Make an object to represent our server. $server = new xmlrpc_client('/mywp/wordpress/xmlrpc.php', 'localhost', 80); // Send a message to the server. $message = new xmlrpcmsg('xmlrpc.wp_newPage', array(new xmlrpcval(1, 'int'), new xmlrpcval('admin', 'string'), new xmlrpcval('mpass', 'string'), new xmlrpcval('mycontect', 'string'), new xmlrpcval('publish', 'string'))); $result = $server->send($message); ?> </body></html>
it work with no error but nothing insert in my database,i am confused on how i should send parameter to this function , would you plz help me by simple sample .
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘publish new post from another website by xmlrpc’ is closed to new replies.