Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- // WP XMLRPC POST
- function api_post($rpc, $method, $filter){
- $USERNAME = "";
- $PASSWORD = "";
- $status = $rpc->query($method, "1", $USERNAME, $PASSWORD, $filter);
- if(!$status){
- print "Error (".$rpc->getErrorCode()."):";
- print $rpc->getErrorMessage()."\n";
- exit;
- }
- $comment = $rpc->getResponse();
- return $comment;
- }
- function do_post($type, $isi, $kategori, $judul, $domen){
- $post_req['post_type'] = $type;
- $post_req['post_status'] = 'publish';
- $post_req['post_title'] = $judul;
- $post_req['post_author'] = 1;
- $post_req['post_excerpt'] = '';
- $post_req['post_content'] = $isi;
- $post_req['post_parent'] = 0;
- $post_req['post_format'] = 'standard';
- $post_req['post_password'] = '';
- $post_req['comment_status'] = 'open';
- $post_req['terms_names']['category'][0] = $kategori;
- $post_req['custom_fields'][0]['key'] = 'post_views_count';
- $post_req['custom_fields'][0]['value'] = 0;
- $isi_post = api_post($rpc, 'wp.newPost', $post_req);
- $slug = api_post($rpc, 'wp.getPost', $isi_post);
- return '<a href="http://'.$domen.'/'.$slug['post_name'].'">'.$slug['post_title'].'<a><br>';
- }
- ?>
- /*
- disini form atur2 episode..
- pake jquery buat nambah form episode / gmn gt..
- <?php
- if(isset(....)){
- // pake aja foreach / while / for, buat looping
- require "IXR_Library.php";
- $target_domain = "";
- $rpc = new IXR_Client('http://'.$target_domain.'/xmlrpc.php');
- echo do_post($type, $isi, $kategori, $judul, $target_domain);
- ?>
- */
- ///// TESTING
- <?php
- require "IXR_Library.php";
- $target_domain = "anu.com";
- $judul = 'testing judul';
- $type = 'post';
- $kategori = 'testing kategori';
- $isi = 'testing isi post';
- $rpc = new IXR_Client('http://'.$target_domain.'/xmlrpc.php');
- echo do_post($type, $isi, $kategori, $judul, $target_domain);
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement