Creating Tables by API

For discussion of the Poker Mavens server module and other administration topics
CanadaWest
Posts: 107
Joined: Wed May 06, 2009 12:59 pm
Contact:

Creating Tables by API

Post 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?
Attachments
CreateRingGame.zip
(1.4 KiB) Downloaded 505 times
George
(CanadaWest)
www.playersclub.ca
Kent Briggs
Site Admin
Posts: 5878
Joined: Wed Mar 19, 2008 8:47 pm

Re: Creating Tables by API

Post 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.
CanadaWest
Posts: 107
Joined: Wed May 06, 2009 12:59 pm
Contact:

Re: Creating Tables by API

Post 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.
George
(CanadaWest)
www.playersclub.ca
Kent Briggs
Site Admin
Posts: 5878
Joined: Wed Mar 19, 2008 8:47 pm

Re: Creating Tables by API

Post 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);
Kent Briggs
Site Admin
Posts: 5878
Joined: Wed Mar 19, 2008 8:47 pm

Re: Creating Tables by API

Post 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;
}
CanadaWest
Posts: 107
Joined: Wed May 06, 2009 12:59 pm
Contact:

Re: Creating Tables by API

Post 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
George
(CanadaWest)
www.playersclub.ca
Kent Briggs
Site Admin
Posts: 5878
Joined: Wed Mar 19, 2008 8:47 pm

Re: Creating Tables by API

Post 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.
MonTheHoops
Posts: 48
Joined: Sat Jun 21, 2008 3:39 pm

Re: Creating Tables by API

Post 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
Kent Briggs
Site Admin
Posts: 5878
Joined: Wed Mar 19, 2008 8:47 pm

Re: Creating Tables by API

Post 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)) .
MonTheHoops
Posts: 48
Joined: Sat Jun 21, 2008 3:39 pm

Re: Creating Tables by API

Post 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
Post Reply