CloudPlayDev / confluence-php-client

PHP ^7.4||^8.0 PSR-7 library for communication with Confluence
MIT License
7 stars 4 forks source link

Content type "blog post" #12

Open mzeis opened 1 month ago

mzeis commented 1 month ago

Hi, first: thank you a lot for providing this package!

I was wondering if you would accept a PR for adding the ability to create blog posts?

From a quick test, I could post a blog to Confluence Cloud by creating a class \CloudPlayDev\ConfluenceClient\Entity\ContentBlogPost which extends \CloudPlayDev\ConfluenceClient\Entity\AbstractContent defining a $type "blogpost" and extending the existing code which works with ContentPage and ContentComment classes so that is also can handle blog posts.

Example usage code:

$confluenceClient = new ConfluenceClient($confluenceHost);
$confluenceClient->authenticateBasicAuth($confluenceUser, $confluenceToken);

$post = new ContentBlogPost();
$post->setSpace($space);
$post->setTitle($title);
$post->setContent($content);

$result = $confluenceClient->content()->create($post);
astepin commented 3 days ago

Hi @mzeis,

I am glad that this package has been helpful to you.

I would be happy if we could work on the BlogPost topic. The body of a blog can have two types of content: BlogPostBodyWrite, BlogPostNestedBodyWrite. We should take these into account.

AbstractContent has properties like Children, Ancestors which I don't think a BlogPost has.

Maybe you can make a draft and we can see together what we can make of it.

mzeis commented 2 days ago

Hi @astepin,

thank you for your response and detailing the next steps.

To get things working, I created an internal fork with the mentioned changes, and this works for creating our type of blog post. I'll try to find time to create a draft for a proper integration - I cannot promise anything on the timeframe, unfortunately.

Besides the mentioning of BlogPostBodyWrite and BlogPostNestedBodyWrite in the API, do you know of any more information from Atlassian for the concepts / usage etc. that would help us here?

astepin commented 2 days ago

I don't really know the exact background and concepts behind the blogs yet. I haven't used this type of content yet. I'll probably have to catch up on that.

There is also the normal content that you can create with the “blogpost” type. But apparently there is also a separate API just for blogposts. You have to check that first.

The blogpost API is also only available in v2.

https://developer.atlassian.com/cloud/confluence/rest/v2/api-group-blog-post/