gn36/phpbb-oo-posting-api

用于在phpBB中创建/修改帖子、主题和私信的辅助类,可以由其他扩展添加到供应商。

dev-master 2015-01-20 00:00 UTC

This package is auto-updated.

Last update: 2024-08-25 06:47:37 UTC


README

此存储库包含一个用于在phpBB中简单创建和编辑帖子及私信的API。它添加了帖子、主题和私信的类。这些类可以在扩展中集成。这些类在后台处理所有必要的参数处理,因此只需设置新的帖子的 forum_id、标题和文本,类将处理其余部分。在文本中可以正常使用任何可用的bbcode。对于私信,可以轻松设置收件人。

警告:开发仍处于早期阶段,此API中可能仍存在重大错误。目前,只有post和privmsg类可供使用,这意味着没有处理附件和投票。目前也无法加载私信进行编辑。

安装

gn36/phpbb-oo-posting-api 添加到您的扩展 composer 依赖项中,并使用 composer 进行安装。

使用

要在论坛中创建一个论坛_id = 1 的新主题

$post = new \Gn36\OoPostingApi\post();

$post->forum_id = 1;
$post->post_subject = 'Subject of the new topic';
$post->post_text = 'The text of the first post. [b]This is bold![/b]';

// This is optional: Change the author id. Default is current user.
$post->poster_id = ANONYMOUS; // Create a guest post (could be any user id)
// This is only necessary for guests if you want a name to appear at the post
$post->post_username = 'I am a guest';

// Submit
$post->submit();

要在主题_id = 1 的主题中创建一个回复

$post = new \Gn36\OoPostingApi\post();

$post->topic_id = 1;
$post->post_subject = 'Subject of the new post';
$post->post_text = 'The text of the reply. [i]This can also contain bbcodes.[/i]';

$post->submit();

要编辑帖子_id = 1 的帖子

$post = \Gn36\OoPostingApi\post::get(1);
$post->post_text = 'This is the new post text';

// This will also change the topic title if you edit the first post:
$post->post_subject = 'This is the new post title';

$post->submit();

要向用户_id = 2 和组_id = 5 的组创建新的私信

$pm = new \Gn36\OoPostingApi\privmsg();

$pm->to(2); // Send to user with id 2
$pm->to('g', 5); // Send to group with id 5

$pm->message_subject = 'The subject of the pm';
$pm->message_text = 'This is the text.
	Again [b]bold[/b] and [color=red]any other[/color] bbcode are allowed.';

$pm->submit();

要回复消息_id = 11 的私信

//reply_to(11, false) disables quoting the original text
$pm = \Gn36\OoPostingApi\privmsg::reply_to(11);

$pm->message_text .= 'The original message will be quoted and this text appears below.
	You could also replace the original text, but if you do so, consider passing a second parameter to	privmsg::reply_to, so it does not load the original text at all.';

// Nothing else needed, recipients are set automatically:
$pm->submit();

开发

如果您发现错误,请在此处报告:https://github.com/gn36/phpbb-oo-posting-api

自动化测试

我们将使用包括功能测试在内的自动化单元测试来防止回归。查看下面的travis构建

master: Build Status

许可证

GPLv2