Page 1 of 1

Api editing site information

Posted: Thu Sep 02, 2010 8:37 am
by coyote
Hi
Is it possible to have an API for editing text site news ?

Re: Api editing site information

Posted: Thu Sep 02, 2010 9:14 am
by Kent Briggs
coyote wrote:Hi
Is it possible to have an API for editing text site news ?
See the SystemGet and SystemSet commands in the docs. Those apply to every setting on the System tab.

Re: Api editing site information

Posted: Fri Sep 03, 2010 4:31 am
by coyote
If I use this function I have only the first line of text

Code: Select all

<?php
  // Connexion au serveur de jeu
 include "API.php";  // $pw and $url set in this file

  $params = "Password=" . $pw . "&Command=SystemGet&Property=SiteNews";
  $api = Poker_API($url,$params,true);
  $result = $api["Result"];
  if ($result == "Error") die("Error: " . $api["Error"]);
  $sitenews = $api["Value"];

?>
How to get it in full and be able to edit?
if feasible course
in any case thank you for the help I have been very useful ;)

Re: Api editing site information

Posted: Fri Sep 03, 2010 9:49 am
by Kent Briggs
coyote wrote:If I use this function I have only the first line of text
The carriage return/line feeds in the Site News are messing up the associated array in $api[]. The easiest workaround is to replace them with html break tags. So instead of this:

This is the site news
This is line 2
This is line 3

You enter it as one long line like this:

This is the site news<br/>This is line 2<br/>This is line 3

If you don't want to do that, then change the call to Poker_API() so that the third parameter is false like this:

$api = Poker_API($url,$params,false);

That means that the $api[] array is now just a regular array where you access the elements by their index number:

$api[0] = "Result=Ok"
$api[1] = "Value=This is the site news"
$api[2] = "This is line 2"
$api[3] = "This is line 3"

You'll have to manually loop through the array and pull out the individual lines.