topical media & game development

talk show tell print

mashup-delicious-06-example6-9-index.php / php



  <?php
  //bring in XML-RPC for PHP goodness
  include('lib/xmlrpc.inc');
  
  //set this to the host and location for your wordpress xmlrpc.php server
  xml_rpc_server_host = 'localhost';
  xml_rpc_server_location = '/wordpress/xmlrpc.php';
  //the wordpress username and password you want to post as
  wp_username = 'admin';
  wp_password = 'password';
  
  //create the xml-rpc client object
  client = new xmlrpc_client(xml_rpc_server_location, xml_rpc_server_host, 80);
  
  //create an array for our post data
  post = array();
  post['title']="Test Post using XML-RPC";
  post['description']="Hello XML-RPC world!";
  
  //assemble the xml-rpc message
  paramaters = array(
              php_xmlrpc_encode("1"),
              php_xmlrpc_encode(wp_username),
              php_xmlrpc_encode(wp_password),
              php_xmlrpc_encode(post),
              php_xmlrpc_encode("1")
          );
  message = new xmlrpcmsg("metaWeblog.newPost",paramaters);
  
  //what do we want our response to be?
  client->return_type = 'phpvals';
  
  //send the XML-RPC message to the server
  response = client->send(message);
  
  //print the response (if errno=0, the post was a sucess!)
  echo "<pre>";
  print_r(response);
  echo "</pre>";
  ?>
  


(C) Æliens 20/2/2008

You may not copy or print any of this material without explicit permission of the author or the publisher. In case of other copyright issues, contact the author.