Page 1 of 2

Creating Tables by API

Posted: Mon Aug 24, 2009 6:25 pm
by CanadaWest
Hi kent,

I wrote a PHP form to allow my players to create their own Ring Games. Zipped and Attached

Trouble is, they are created in Off-Line state. How do I get them to go online automatically?

Re: Creating Tables by API

Posted: Mon Aug 24, 2009 6:35 pm
by Kent Briggs
CanadaWest wrote: I wrote a PHP form to allow my players to create their own Ring Games. Zipped and Attached
Trouble is, they are created in Off-Line state. How do I get them to go online automatically?
Call the RingGamesOnline command after creating it with a "Name" parameter set to the table name.

Re: Creating Tables by API

Posted: Mon Aug 24, 2009 7:15 pm
by CanadaWest
So that the player doesnt have to remember EXACTLY what he named the new table..

Is there a way to pass the new Name parameter to a RingGamesOnline command automatically?

Maybe via GET? (probably not because would have to url encode it)

Can I put a second command or form in the echo returned on successful creation of the table?

I'm probably missing something simple. i have a headache.

Re: Creating Tables by API

Posted: Mon Aug 24, 2009 8:22 pm
by Kent Briggs
CanadaWest wrote:So that the player doesnt have to remember EXACTLY what he named the new table..
Your script should be calling one command right after the other. You already got the name in your code when you did this:

$Name = $_REQUEST["Name"];

So right after the first Poker_API() comes back, build a new param list and call it again:

$params = "Password=$pw&Command=RingGamesOnline&Name=" . urlencode($Name) ;
$api = Poker_API($url,$params,true);

Re: Creating Tables by API

Posted: Mon Aug 24, 2009 8:27 pm
by Kent Briggs
CanadaWest wrote:Can I put a second command or form in the echo returned on successful creation of the table?
To group multiple commands together on the result of an if statement in PHP, you just surround them in curly braces:

Code: Select all

if ($myvar == "myvalue")
{
  DoThis1;
  DoThis2;
  DoThis3;
}
else
{
  DoThat1;
  DoThat2;
  DoThat3;
}

Re: Creating Tables by API

Posted: Mon Aug 24, 2009 8:50 pm
by CanadaWest
Kent Briggs wrote:
So right after the first Poker_API() comes back, build a new param list and call it again:

$params = "Password=$pw&Command=RingGamesOnline&Name=" . urlencode($Name) ;
$api = Poker_API($url,$params,true);
I didn't know you could put two commands in the same script! A whole new world of possibilities!

LOL
Thanks

Re: Creating Tables by API

Posted: Mon Aug 24, 2009 9:16 pm
by Kent Briggs
CanadaWest wrote:I didn't know you could put two commands in the same script! A whole new world of possibilities!
Oh yeah, look at some of my PHP examples at http://www.briggsoft.com/docs/pmavens/API_Examples.htm. The Player Search function makes 7 API calls there.

Re: Creating Tables by API

Posted: Tue Aug 25, 2009 12:37 pm
by MonTheHoops
Just tried this one but I get an error when I try to create a table, it says Invalid Game Type specified, click back to try again.

Cheers

Re: Creating Tables by API

Posted: Tue Aug 25, 2009 1:32 pm
by Kent Briggs
MonTheHoops wrote:Just tried this one but I get an error when I try to create a table, it says Invalid Game Type specified, click back to try again.
The form is escaping the apostrophe in Hold'em with a slash so change this line:

"&Game=" . urlencode($Game) .

to this:

"&Game=" . urlencode(stripslashes($Game)) .

Re: Creating Tables by API

Posted: Tue Aug 25, 2009 1:41 pm
by MonTheHoops
Cheers Kent, got that to work now. Just waiting for the code to put the created games online as I'm completely clueless on the coding side of things, I just cant get my head around it at all..I've tried :D