Creating Tables by API

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

Creating Tables by API

Postby CanadaWest » Mon Aug 24, 2009 6:25 pm

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 204 times
George
(CanadaWest)
www.playersclub.ca
CanadaWest
 
Posts: 107
Joined: Wed May 06, 2009 12:59 pm

Re: Creating Tables by API

Postby Kent Briggs » Mon Aug 24, 2009 6:35 pm

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.
Kent Briggs - [email protected]
Briggs Softworks - http://www.briggsoft.com
Kent Briggs
Site Admin
 
Posts: 3763
Joined: Wed Mar 19, 2008 8:47 pm

Re: Creating Tables by API

Postby CanadaWest » Mon Aug 24, 2009 7:15 pm

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

Re: Creating Tables by API

Postby Kent Briggs » Mon Aug 24, 2009 8:22 pm

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 - [email protected]
Briggs Softworks - http://www.briggsoft.com
Kent Briggs
Site Admin
 
Posts: 3763
Joined: Wed Mar 19, 2008 8:47 pm

Re: Creating Tables by API

Postby Kent Briggs » Mon Aug 24, 2009 8:27 pm

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;
}
Kent Briggs - [email protected]
Briggs Softworks - http://www.briggsoft.com
Kent Briggs
Site Admin
 
Posts: 3763
Joined: Wed Mar 19, 2008 8:47 pm

Re: Creating Tables by API

Postby CanadaWest » Mon Aug 24, 2009 8:50 pm

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

Re: Creating Tables by API

Postby Kent Briggs » Mon Aug 24, 2009 9:16 pm

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.
Kent Briggs - [email protected]
Briggs Softworks - http://www.briggsoft.com
Kent Briggs
Site Admin
 
Posts: 3763
Joined: Wed Mar 19, 2008 8:47 pm

Re: Creating Tables by API

Postby MonTheHoops » Tue Aug 25, 2009 12:37 pm

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

Re: Creating Tables by API

Postby Kent Briggs » Tue Aug 25, 2009 1:32 pm

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)) .
Kent Briggs - [email protected]
Briggs Softworks - http://www.briggsoft.com
Kent Briggs
Site Admin
 
Posts: 3763
Joined: Wed Mar 19, 2008 8:47 pm

Re: Creating Tables by API

Postby MonTheHoops » Tue Aug 25, 2009 1:41 pm

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

Next

Return to Site Administration

Who is online

Users browsing this forum: No registered users and 2 guests

cron