Site News

For discussion of the Poker Mavens server module and other administration topics

Site News

Postby mike123 » Wed Dec 29, 2010 1:01 pm

Hello i want to add the site news on the software to a webpage.. how can i do that ? thank you
mike123
 
Posts: 72
Joined: Tue Feb 16, 2010 7:30 am

Re: Site News

Postby Kent Briggs » Wed Dec 29, 2010 1:23 pm

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".
Kent Briggs - [email protected]
Briggs Softworks - http://www.briggsoft.com
Kent Briggs
Site Admin
 
Posts: 3788
Joined: Wed Mar 19, 2008 8:47 pm

Re: Site News

Postby mike123 » Thu Dec 30, 2010 7:25 pm

is that wrong ?


<?php
include "API.php";

$news = $api["SiteNews"];



echo "$news";

?>
mike123
 
Posts: 72
Joined: Tue Feb 16, 2010 7:30 am

Re: Site News

Postby Kent Briggs » Thu Dec 30, 2010 8:56 pm

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.
Kent Briggs - [email protected]
Briggs Softworks - http://www.briggsoft.com
Kent Briggs
Site Admin
 
Posts: 3788
Joined: Wed Mar 19, 2008 8:47 pm


Return to Site Administration

Who is online

Users browsing this forum: No registered users and 5 guests

cron