Register to post in forums, or Log in to your existing account
 

Play RetroMUD
Post new topic  Reply to topic     Home » Forums » CMUD General Discussion
Ardath
Beginner


Joined: 17 Jan 2010
Posts: 20

PostPosted: Wed Oct 06, 2010 9:43 pm   

%url function question (Cmud3 Pro)
 
I can't get it to work. This is from the More Help document on %url:

Code:
u = %url("www.server.com")
@u.PostParams.name = zugg
@u.PostParams.key = value
s = @u.Post

Quote:
Performs an HTTP POST with the PostParams string of "name=zugg&key=value" and stores the result in the @s variable.


The code from the help document does not work.

This is an error message I would get:

Quote:
ERROR: Syntax error in Alias: foo : illegal token: .PostParams.name = zugg


What is the right way to set the properties of a URL Object (i.e. Port and PostParam properties)?
Reply with quote
Tech
GURU


Joined: 18 Oct 2000
Posts: 2733
Location: Atlanta, USA

PostPosted: Thu Oct 07, 2010 3:49 pm   
 
I've never really used this but something quirky seems to be happening here. I'm seeing the same behavior.
_________________
Asati di tempari!
Reply with quote
Anaristos
Sorcerer


Joined: 17 Jul 2007
Posts: 821
Location: California

PostPosted: Fri Oct 08, 2010 12:01 am   
 
Try it this way:
Code:

#VAR u %url( "www.server.com")
;;
$db.name = "zugg"
$db.key  = "software"
;;
u.PostParams = $db
;;
s = @u.Post
;;
#PRINT %json( @u.PostParams).name

The print outputs the following:
Quote:

zugg

I don't know what result is expected, though:
Quote:

s => HTTP/1.1 408 Request Timeout

Here is the xml:
Code:

<alias name="test" id="1">
 <value>#VAR u %url( "www.server.com")
;;
$db.name = "zugg"
$db.key  = "software"
;;
u.PostParams = $db
;;
s = @u.Post
;;
#ECHO %json( @u.PostParams).name
</value>
  </alias>
  <var name="u" id="5"></var>
  <var name="s" id="6">HTTP/1.1 408 Request Timeout</var>
_________________
Sic itur ad astra.
Reply with quote
Zugg
MASTER


Joined: 25 Sep 2000
Posts: 23379
Location: Colorado, USA

PostPosted: Sun Oct 10, 2010 3:48 pm   
 
Code:
u = %url("www.server.com")
@u.PostParams.name = zugg
@u.PostParams.key = value
s = @u.Post

Do not put @ in front of the variable when making the assignment. The correct code is:
Code:
u = %url("www.server.com")
u.PostParams.name = zugg
u.PostParams.key = value
s = @u.Post

Edited: WRONG See post below for corrected code.


Last edited by Zugg on Wed Apr 20, 2011 5:23 pm; edited 2 times in total
Reply with quote
Ardath
Beginner


Joined: 17 Jan 2010
Posts: 20

PostPosted: Tue Apr 12, 2011 8:36 pm   
 
I tried running that code from a trigger. The error I get from that is:

Quote:
No method/property name: PostParams.name.


It comes up with a window named "Error in cMUDPro.exe" where I usually "Continue application" or I can also view the call stack.
Reply with quote
Ardath
Beginner


Joined: 17 Jan 2010
Posts: 20

PostPosted: Tue Apr 12, 2011 9:12 pm   
 
Code:
#addkey @u.PostParams {name=zugg}


Using that to set the PostParams may help.

That gets it further, but the .php page I passed into the %url() function still will not echo back the parameter.
Reply with quote
Zugg
MASTER


Joined: 25 Sep 2000
Posts: 23379
Location: Colorado, USA

PostPosted: Wed Apr 13, 2011 4:16 pm   
 
It looks like something in the %url function broke in one of the recent releases. I'll add this to the bug list for the next update.

Also, the example in the %url help file isn't correct, so I'll try to update that too.

(P.S. In the future you should make a new post in the correct forum since CMUD is no longer in Beta instead of bumping an old thread. I have moved this post to the correct forum)
Reply with quote
Zugg
MASTER


Joined: 25 Sep 2000
Posts: 23379
Location: Colorado, USA

PostPosted: Wed Apr 20, 2011 5:22 pm   
 
I have updated the help file for the %url topic to reflect the correct way to use PostParams and Params in v3.34. Since %url returns a COM variable, the way you work with PostParams and Params is a bit different than normal CMUD database variables. The correct code example is:
Code:
u = %url("www.server.com")
u.PostParams("name") = zugg
u.PostParams("key") = value
s = @u.Post
Reply with quote
Display posts from previous:   
Post new topic   Reply to topic     Home » Forums » CMUD General Discussion All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

© 2009 Zugg Software. Hosted by Wolfpaw.net