Page 1 of 1

Account balance

Posted: Sun Jan 30, 2011 10:53 am
by narayan
Hello, I have a simple question for all of you, and very complicated for me.
I want to show the balance of a particular player on the website, I want to use this function:

function Poker_API($url,$params,$assoc)
{
$curl = curl_init($url);
curl_setopt($curl,CURLOPT_POST,true);
curl_setopt($curl,CURLOPT_POSTFIELDS,$params);
curl_setopt($curl,CURLOPT_TIMEOUT,30);
curl_setopt($curl,CURLOPT_RETURNTRANSFER,true);
$response = trim(curl_exec($curl));
curl_close($curl);
$api = Array();
if ($assoc) // associative array result
{
if (empty($response))
{
$api["Result"] = "Error";
$api["Error"] = "Connection failed";
}
else
{
$paramlist = Explode("\r\n",$response);
foreach ($paramlist as $param)
{
$namevalue = Explode("=",$param,2);
$api[$namevalue[0]] = $namevalue[1];
}
}
}
else // regular array result
{
if (empty($response))
{
$api[] = "Result=Error";
$api[] = "Error=Connection failed";
}
else
{
$paramlist = Explode("\r\n",$response);
foreach ($paramlist as $param) $api[] = $param;
}
}
return $api;
}


what are the next line so I can show the balance for the next player ?

Player : TEST
Password: 123456

Thank you !

Re: Account balance

Posted: Sun Jan 30, 2011 11:48 am
by Kent Briggs
narayan wrote: what are the next line so I can show the balance for the next player ?
Player : TEST
Password: 123456
Use the AccountsGet command in the API. Something like this:

Code: Select all

<?php
  include "API.php";  // API password assigned to $pw in here

  $player = "TEST";   // assume these values retrieved from input form
  $playerpw = "123456";

  $params = "Password=" . $pw . "&Command=AccountsGet&Player=" . $player;
  $api = Poker_API($url,$params,true);
  $result = $api["Result"];
  if ($result == "Error") die("Error: " . $api["Error"]);
  if ($api["PW"] != $playerpw) die("Password is incorrect");
  echo "Chip balance for " . $player . " is " . $api["Balance"];
?>


Re: Account balance

Posted: Sun Jan 30, 2011 12:17 pm
by narayan
thank you, it worked