|
|
Forum moderator: bigblog |
uCoz Community For Webmasters Custom Solutions Help with script that sends forum updates in the chatbox (Informer that posts forum updates inside chatbox) |
Help with script that sends forum updates in the chatbox |
Hi,this topic and description says it all and I used chatGBT to help create the code and I did some modifications but I'm not a pro so can I get some help please??
Code ``` <script src="https://code.jquery.com/jquery-3.6.0.min.js"></script> <script> $(document).ready(function() { // Set the interval for fetching updates (in milliseconds) var updateInterval = 30000; // 30 seconds // Define the function to fetch updates and send them as chat messages function sendForumUpdates() { // Use Ucoz API to fetch the latest forum updates $.get('https://242mb.ucoz.club/forum/get_posts', { forum_id: <$FID$>, sort_by: 'date', order_by: 'desc', limit: 10 }, function(data) { // Extract the latest forum updates var forumUpdates = data.posts; // Send each update as a chat message forumUpdates.forEach(function(update) { var cMessage = 'New forum update: ' + update.title; // Use Ucoz API to send message to chatbox $.post('https://242mb.ucoz.club/mchat/send', { cMessage: $MESSAGE$ }); }); }); } // Call the function to send forum updates every `updateInterval` milliseconds setInterval(sendForumUpdates, updateInterval); }); </script> ``` Like where do I put it and why won't it work?? |
| |||
| |||