Site News
-
- Site Admin
- Posts: 5880
- Joined: Wed Mar 19, 2008 8:47 pm
Re: Site News
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".mike123 wrote:Hello i want to add the site news on the software to a webpage.. how can i do that ? thank you
Re: Site News
is that wrong ?
<?php
include "API.php";
$news = $api["SiteNews"];
echo "$news";
?>
<?php
include "API.php";
$news = $api["SiteNews"];
echo "$news";
?>
-
- Site Admin
- Posts: 5880
- Joined: Wed Mar 19, 2008 8:47 pm
Re: Site News
Try something linke this:
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.
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>
$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.