mybb - 如何检查新的私人消息
我正在尝试为我的网站构建一个 chrome 应用程序/扩展程序,该网站主要是一个 mybb 论坛。我想知道是否有人知道我如何检查用户的线程上是否有新的 Pm 或新帖子?也许通过 JS、AJAX 或 PHP
I'm trying to build an chrome app/extension for my website which is mostly a mybb forum. I am wondering if anybody knows how would I check to see if a user has new Pm's or maybe new posts on his thread? Maybe by JS, AJAX, or PHP
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
就事件而言,通常对于 PM 来说,数据库中有一个名为“read”的字段,如果他们没有打开它,则该字段为 false,如果打开则为 true。在页面加载时,检查是否有任何给用户的消息是“未读”的,如果有,加载它们,并使用 JQuery 弹出一个简短的描述。您还可以使用一个小型 AJAX 脚本定期检查这一点。
就新帖子而言,我所看到的传统方式(但绝不是最好的方式)是保留用户上次访问该网站的时间戳。页面加载时,获取在该时间戳之后创建的每个新帖子/主题,然后序列化此数据并将其存储在数据库或 cookie 中(如果此序列化数据已存在,则将其反序列化,合并两者并重新序列化) 。如果用户访问某个主题,则从匹配的序列化条目中获取所有数据(IE,在同一主题中,或帖子编号),并将其从序列化数据中删除。然后再次在页面加载时或通过使用 AJAX 脚本,定期检查他们是否在属于他们的主题上有“未读”帖子(IE,在其最后一个时间戳值之后创建),并使用一些 JQuery 来通知他们。
As far as events go, generally for PM's there is a field in the database called 'read', which is false if they haven't opened it, and true if they have. On a page load, check to see if there are any messages to the user that are 'unread', and if so, load them, and use JQuery to make a pop up saying a short description of them. You could also have a small AJAX script periodically check for this.
As far as new posts go, the traditional way that I've seen it done (but by no means the best way) is to keep a timestamp of when a user last visited the site. On page load, get every new post/topic that was created after that timestamp, then serialize this data and store it in the database, or in a cookie (if this serialized data already exists, unserialize it, merge the two and reserialize it). If a user visits a topic, get all data from the serialized entry that matches (IE, in the same topic, or the post number) and remove it from the serialized data. Then again on page load or by using an AJAX script, check periodically if they have an 'unread' post on a topic that belong to them (IE, created after their last timestamp value), and use a bit of JQuery to notify them.