PHP XML-RPC. Who will show a live example of posting in Wordpress with categories and a couple of tags, as a result should be shown the identifier of the new record, in general, a classic?

thank

    1 answer 1

    I use this code:

    require_once ('IXR_Library.php'); $client = new IXR_Client('http://my_blog.com/xmlrpc.php'); $client->timeout = 60000; $requestData[0] = 0; //id Π±Π»ΠΎΠ³Π° $requestData[1] = 'admin'; //имя ΠΏΠΎΠ»ΡŒΠ·ΠΎΠ²Π°Ρ‚Π΅Π»Ρ $requestData[2] = 'pass'; //ΠΏΠ°Ρ€ΠΎΠ»ΡŒ $post = array(); $post['post_title'] = 'New Post'; $post['post_excerpt'] = 'Short description'; $post['post_content'] = 'This story about ...'; $post['post_status'] = 'draft'; $post['post_type'] = 'my_custom_post_type'; //Ρ‚ΠΈΠΏ поста $post['post_date'] = date('Ymd H:i:s'); $post['post_modified'] = date('Ymd H:i:s'); //Ρ„ΠΎΡ€ΠΌΠΈΡ€ΡƒΠ΅ΠΌ массив с Ρ‚Π΅Ρ€ΠΌΠΈΠ½Π°ΠΌΠΈ таксономий $terms = array(); $terms['taxonomy_1'][] = (int)$term['term_id_1']; $terms['taxonomy_1'][] = (int)$term['term_id_2']; $terms['taxonomy_2'][] = (int)$term['term_id_3']; $terms['taxonomy_3'][] = (int)$term['term_id_4']; $post['tax_input'] = $terms; $requestData[3] = $post; if (!$client->query('my.publish_post', $requestData)) { echo 'Publish Post error: '.$client->getErrorMessage(); return; } $publishedPost = $client->getResponse(); 

    A source