victor-stm / confluence
Confluence API ADF 助手
2.1.1
2021-06-21 14:35 UTC
Requires (Dev)
- phpunit/phpunit: ^9.5
This package is not auto-updated.
Last update: 2024-09-24 03:50:22 UTC
README
帮助使用PHP构建并发布到Confluence的文档。
示例
在./example/demo-page.php的config部分设置您的秘密,然后运行脚本
php example/demo-page.php
用法
// config
$apiURL = 'domain.without.schema'; // Correct: 'x.atlassian.net', WRONG: 'https://x.atlassian.net'
$apiToken = 'user:api_token';
$pageID = '12378764';
$pageTitle = ''; // use page's title
$pageSpace = 'MY';
$confAPI = new Confluence ($apiURL, $apiToken);
//---------------------------------------------------------------------
// Content build
//---------------------------------------------------------------------
$content = new Content ();
//---------------------------------------------------------------------
// Headers
//---------------------------------------------------------------------
$h1 = new Header ('Header H1');
$h1->level = 1;
$h2 = new Header ('Header H2', 2);
$content->add ($h1)
->add ($h2)
->add (new Header ('Header H3, etc.', 3));
//---------------------------------------------------------------------
// Paragraph
//---------------------------------------------------------------------
$p = new Paragraph ('Hello, ');
$p->add (new Text('world!'))
->add (new Text(' And here is a link example: '))
->add (new TextWithLink('Google.com', 'https://google.com/'));
$content->add ($p);
//---------------------------------------------------------------------
// Table Node
//---------------------------------------------------------------------
$table = new Table ();
$table->attributes->layout = TableAttributes::LAYOUT_FULL_WIDTH;
//---------------------------------------------------------------------
// First row with header nodes
//---------------------------------------------------------------------
$headerRow = new TableRow ();
$table->add ($headerRow);
$headTime = new TableHeader ('Time');
$headTime->attributes->colwidth = [150];
$headProject = new TableHeader ('Project');
$headProject->attributes->colwidth = [220];
$headerRow->add ($headTime)
->add ($headProject)
->add (new TableHeader ('Message'));
//---------------------------------------------------------------------
// Rows
//---------------------------------------------------------------------
$table->add ((new TableRow())
->add (new TableCell ('00:00:00'))
->add (new TableCell ('Row 1 Project'))
->add (new TableCell ('Row 1 Message'))
);
// OR
$row = new TableRow();
$row->add (new TableCell ('00:00:00'));
$row->add (new TableCell ('Row 2 Project'));
$row->add (new TableCell ('Row 2 Message'));
$table->add ($row);
//---------------------------------------------------------------------
// Add table to content & update existing page
//---------------------------------------------------------------------
$content->add ($table);
$confAPI->updatePage ($pageID, $content, $pageTitle, $pageSpace);
预期结果:
许可证
遵循MIT许可证MIT license。