wp-api-v2-client-java
wp-api-v2-client-java copied to clipboard
Can this be used to add podcast episodes to PowerPress?
https://forum.blubrry.com/index.php?topic=3466.0 I read here that you need to add information to custom fields in order to do this
`$enclosure_value = $row['url']; $enclosure_value .= "\n"; $enclosure_value .= $row['size']; $enclosure_value .= "\n"; $enclosure_value .= $type;
$content['title'] = $title;
$content['description'] = $body;
$content['categories'] = array("Meetings");
/*Pass custom fields*/
$content['custom_fields'] = array(
array( 'key' => 'enclosure', 'value' => $enclosure_value )
);`
Can this be done using this java library? Thank you
Hi @paratechnical, if you look at com.afrozaar.wordpress.wpapi.v2.Client and the meta
methods, you'll be able to do that.
So you'll for example use client.createMeta(postId, "enclosure", "enclosure value");
.
Hi @johanmynhardt , what if there is no postid, what if I am creating it now? Do I create it first and then add the meta? Is there a documentation or an example somewhere that I can check out? Thanks
@paratechnical you can have a look in /src/test/java/com/afrozaar/wordpress/wpapi/v2/ClientLiveIT.java#L358
You do need a post. This is something required by the wordpress REST API.
@paratechnical that ClientLiveIT
class is where you'll get all the cases that I had to make it work with.
@johanmynhardt Do you have any idea why
PostMeta createdMeta = client.createMeta(createdPost.getId(), key, value);
might crash with a 404 error?
It could be a permission issue or the rest endpoint could have an issue.
If you initialised the client with debugging enabled, you should be able to see more information about the request and response.