playMaker

Author Topic: WWWForm Actions?  (Read 6085 times)

derkoi

  • Full Member
  • ***
  • Posts: 187
WWWForm Actions?
« on: July 26, 2012, 12:27:25 PM »
Has anyone made any WWWForm actions?

Specifically, I'm trying to implement Scoreoid hi scores etc & it uses WWWForms like below:

Code: [Select]
/* Use this for initialization */
    void Start () {
       
        /* API  method */
        string url = "https://www.scoreoid.com/api/createScore";

        /* Unity WWW Class used for HTTP Request */
        WWWForm form = new WWWForm();
       
        form.AddField( "api_key", "YOUR API KEY" );
        form.AddField( "game_id", "YOUR GAME ID");
        form.AddField( "response", "xml");
        form.AddField( "username", "Player username");
        form.AddField( "score", "Player score");
       
        WWW www = new WWW(url, form);
        StartCoroutine(WaitForRequest(www));
    }
   
    IEnumerator WaitForRequest(WWW www)
    {
        yield return www;

        /* Check for errors */
        if (www.error == null)
        {
            Debug.Log("WWW Ok!: " + www.text);
        } else {
            Debug.Log("WWW Error: "+ www.error);
        }   
    }

I could probably get something working myself but before I attempt it, just wondering if anyone has anything already?  :)

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: WWWForm Actions?
« Reply #1 on: July 27, 2012, 05:21:12 AM »
Hi,

 Very nice finding for scoreoid, thanks for the link.
 
 I implemented Parse (https://www.parse.com/) in playmaker using UniParse from the asset store, and this is very similar, only more generic than scoreoid,

What problem are you having exactly? Is it a matter of porting that script into an action?

Bye,

 Jean

derkoi

  • Full Member
  • ***
  • Posts: 187
Re: WWWForm Actions?
« Reply #2 on: July 27, 2012, 05:29:01 AM »
Thanks Jean,

I'm not having any problems yet as I've not started to make the actions, I'm just trying to get in idea for the workload involved.

I think i could handle porting the WWWForms to Actions but I'm completely confused with how to display the XML or JSON data it returns on my leaderboards.

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: WWWForm Actions?
« Reply #3 on: July 27, 2012, 06:22:51 AM »
hi,

 Yes, I think this would be a good excuse to start building actions to treat json strings, It's nothing difficult since anyway I personally would rely on a json parser, and there are plenty.

 As for the ui, It really depends what ui system you want to use.

bye,

 Jean

derkoi

  • Full Member
  • ***
  • Posts: 187
Re: WWWForm Actions?
« Reply #4 on: July 27, 2012, 06:27:16 AM »
The UI im using is NGUI, I'm able to use NGUI with Playmaker using set property and also the NGUI input script for buttons.

So you'd recommend using JSON and find a parser?

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: WWWForm Actions?
« Reply #5 on: July 27, 2012, 07:22:57 AM »
Hi,

 Yes, use a json parser, but you'll still need to write some actions to parse the json anyway, Do you know where to start to do such thing?

 bye,

 Jean

derkoi

  • Full Member
  • ***
  • Posts: 187
Re: WWWForm Actions?
« Reply #6 on: July 27, 2012, 07:24:46 AM »
No Jean, the parser part is all new to me.  :(

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: WWWForm Actions?
« Reply #7 on: July 27, 2012, 09:41:43 AM »
Hi,

 ok, I will not hide the fact that, as always, I am running behind all the pending threads on this forum :) so please get back to me end of august, after Unite, and I will then have caught up with everything and have some free time again. The thing with this is that you'll need custom actions to send the form as well as custom actions to parse the results, which in the end represent a fair amount of work. I am willing to do it, only not able to commit to that before then. If you are part of a project that has budget for thing to move forward right now, let me know and pm me, else do not hesitate to get back to me.


bye,

 Jean

derkoi

  • Full Member
  • ***
  • Posts: 187
Re: WWWForm Actions?
« Reply #8 on: July 27, 2012, 11:44:55 AM »
Thanks Jean, what I think I'm going to do is leave global leaderboards for the time being as this game i'm working on is the lite (free) version with limited functionality, the global leaderboards will be part of the full paid version.

I'm going to focus on the controls for the swipe & get the lite version released.