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 !
Account balance
-
- Site Admin
- Posts: 5880
- Joined: Wed Mar 19, 2008 8:47 pm
Re: Account balance
Use the AccountsGet command in the API. Something like this:narayan wrote: what are the next line so I can show the balance for the next player ?
Player : TEST
Password: 123456
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"];
?>