WordPress.org

Ready to get started?Download WordPress

Forums

XML-RPC metaWeblog.newPost . How to manage enclosures ? (1 post)

  1. ben.IT
    Member
    Posted 1 year ago #

    Hi,
    Does anybody knows how to manage enclosures with metaWeblog.newPost method http://codex.wordpress.org/XML-RPC_MetaWeblog_API.

    I take a look at the method implementation in : wp-includes/class-wp-xmlrpc-server.php and saw those interesting lines :

    // Handle enclosures
    		...
    		if ( is_array( $enclosure ) && isset( $enclosure['url'] ) && isset( $enclosure['length'] ) && isset( $enclosure['type'] ) ) {

    Does any body know how to manage enclosure with this method ?
    I tried this but definitevly doesn't work, post is remotely created but not with enclosure :

    $content = array(
                'title' => 'title',
                'description' => 'description',
                'mt_allow_comments' => 0,  // 1 to allow comments
                'mt_allow_pings' => 0,  // 1 to allow trackbacks
                'post_type' => 'post',
                'mt_keywords' => '',
                'categories' => array(''),
    			'enclosure' => array('url'=>'http://www.education.gov.yk.ca/pdf/pdf-test.pdf','length'=>'','type' =>'')
    );
    
    $params = array(0,'admin','admin',$content,false);
    
    if (!$client->query('metaWeblog.newPost',$params))
    {
    	echo('Error occured while executing method : ' . $client->getErrorCode().":".$client->getErrorMessage());
    }
    
    $response = $client->getResponse();
    var_dump($response) ;

    Greetings,
    ben

Topic Closed

This topic has been closed to new replies.

About this Topic