Account balance

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

Account balance

Postby narayan » Sun Jan 30, 2011 10:53 am

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 !
narayan
 
Posts: 13
Joined: Wed Dec 08, 2010 6:04 am

Re: Account balance

Postby Kent Briggs » Sun Jan 30, 2011 11:48 am

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"];
?>

Kent Briggs - [email protected]
Briggs Softworks - http://www.briggsoft.com
Kent Briggs
Site Admin
 
Posts: 3806
Joined: Wed Mar 19, 2008 8:47 pm

Re: Account balance

Postby narayan » Sun Jan 30, 2011 12:17 pm

thank you, it worked
narayan
 
Posts: 13
Joined: Wed Dec 08, 2010 6:04 am


Return to Site Administration

Who is online

Users browsing this forum: No registered users and 2 guests

cron