Page 1 of 1

Site News

Posted: Wed Dec 29, 2010 1:01 pm
by mike123
Hello i want to add the site news on the software to a webpage.. how can i do that ? thank you

Re: Site News

Posted: Wed Dec 29, 2010 1:23 pm
by Kent Briggs
mike123 wrote:Hello i want to add the site news on the software to a webpage.. how can i do that ? thank you
Any of the System property values can be retrieved via the SystemGet API command. In the case of the Site News text, set the Property parameter to "SiteNews".

Re: Site News

Posted: Thu Dec 30, 2010 7:25 pm
by mike123
is that wrong ?


<?php
include "API.php";

$news = $api["SiteNews"];



echo "$news";

?>

Re: Site News

Posted: Thu Dec 30, 2010 8:56 pm
by Kent Briggs
Try something linke this:

Code: Select all

<html>
<body>
<?php
  include "API.php";  // $pw and $url set in this file
  $params = "Password=" . $pw . "&Command=SystemGet&Property=SiteNews";
  // call with third parameter = false to get result as an ordinary array
  $api = Poker_API($url,$params,false);
  // quit if error found
  if ($api[0] == "Result=Error") die($api[1]);
  // trim "Value=" from beginning of first line
  $news = substr($api[1],6);  
  // append remaining lines together with break tag in between
  for ($i=2; $i<count($api); $i++) $news = $news . "<br/>" . $api[$i];
  // display it
  echo $news; 
?>
</body>
</html>
Note that with most calls to the API, you want the result in an associative array like this:

$api[$Key] = "Some value"

so that it's easy to get the specific parameter you were looking for by its key name. Unfortunately that doesn't work in the case of Site News because it's likely to be in multiple lines and that crashes my Poker_API() routine because it's expecting a Key=Value pair on every line. So what you have to do in this case is call Poker_API() with the third parameter set to false as I did in the example above. That tells the routine to just create $api as an ordinary array with values $api[0], $api[1], $api[2], etc. Then you just have to parse the return values by index numbers instead of key names.