automated administrator messages?
Posted: Sun Dec 27, 2009 3:42 pm
Could it be possible using the API to create different automated administrator messages sent out every 'x' minutes to every table?
Yes, use the RingGamesMessage and the TournamentsMessage calls for that. You'll have to control the timing of that with your code, typically in some kind of loop or via a cron job.Mr.Victor wrote:Could it be possible using the API to create different automated administrator messages sent out every 'x' minutes to every table?
On Linux systems, it's a timer you can set (usually in the cPanel) to launch a program (including PHP scripts) at specific times or specific intervals. Windows has something similar with its Task Scheduler utility.Mr.Victor wrote:What is a cron job? This is pretty new to me.
There's no single broadcasting command so you'll need to get the list of games with RingGamesList and TournamentsList and then loop through those to send out your message.Mr.Victor wrote:What's the parameter that I put after Name= if I want to send to all tables and not just one specifically?
Code: Select all
<?php
include "API.php"; // API $url and $pw values set here
$message = 'This is a test message sent to all active tables. Please ignore.';
// Get list of all ring games and send message.
$url = "http://75.127.91.178:8087/api";
$params = "Password=" . $pw . "&Command=RingGamesList&Fields=Name,Status";
$api = Poker_API($url,$params,true);
if ($result == "Error") die("Error: " . $api["Error"]);
$namestatus = $api["RingGames"];
for ($i = 1; $i <= $namestatus; $i++)
{
$name = $api["Name" . $i];
$status = $api["Status" . $i];
if ($status != 'Playing: 0') // Check to make sure ring game is not empty
// Send message to all ring game tables that aren't empty.
{
$url = "http://75.127.91.178:8087/api";
$params = "Password=" . $pw . "&Command=RingGamesMessage&Name=" . $name . "&Message=" . $message;
$api = Poker_API($url,$params,true);
if ($api[Result] == "Ok") echo "<font color='#00FF00'>Message Sent to " . $name . " Ring Game Table. </font><br />";
else echo "<font color='#FF0000'>Error: " . $api[Error] . ".</font><br />";
}
else
echo "<font color='#FF0000'>" . $name . " table is empty. No message sent. </font><br />";
}
// Get list of all tournaments and send message.
$url = "http://75.127.91.178:8087/api";
$params = "Password=" . $pw . "&Command=TournamentsList&Fields=Name,Status";
$api = Poker_API($url,$params,true);
if ($result == "Error") die("Error: " . $api["Error"]);
$namestatus = $api["Tournaments"];
for ($i = 1; $i <= $namestatus; $i++)
{
$name = $api["Name" . $i];
$status = $api["Status" . $i];
if (strstr($status,"Playing: ")) // Check to make sure tournament is running
// Send message to all tournaments that are running.
{
$url = "http://75.127.91.178:8087/api";
$params = "Password=" . $pw . "&Command=TournamentsMessage&Name=" . $name . "&Message=" . $message;
$api = Poker_API($url,$params,true);
if ($api[Result] == "Ok") echo "<font color='#00FF00'>Message Sent to " . $name . " Tournament Table. </font><br />";
else echo "<font color='#FF0000'>Error: " . $api[Error] . ".</font><br />";
}
else
echo "<font color='#FF0000'>" . $name . " is not running. No message sent. </font><br />";
}
?>
My guess is that you might have some URL unfriendly characters in your table names that need to be encoded. So instead of this:Mr.Victor wrote:Ok I'm very new to php and mostly only use it for includes in my html but PM API has put me up to the challenge. I've written a script to send automated messages to ring games and tournaments and I'm sooooo close to getting it to work but it seems as soon as the code hits an active table something goes wrong. My code is probably not that great but like I said I'm a newb. Please let me know where I went wrong here.
Code: Select all
$params = "Password=" . $pw . "&Command=RingGamesMessage&Name=" . $name . "&Message=" . $message;
Code: Select all
$params = "Password=" . $pw . "&Command=RingGamesMessage&Name=" . urlencode($name) . "&Message=" . urlencode($message);
Every API command supports an optional Log parameter that you can include. See the examples in the help file near the top of the API topic of the Technical Information section. There is also a standalone LogAddEvent function in the API. It's only parameter is "Log".Mr.Victor wrote:also how could I send those results to a log?