MySpace Open Platform

A Place For Developers

Welcome Developers!

in

Welcome!

in

persistant data

Last post 06-09-2009 11:22 AM by rondata. 12 replies.
Page 1 of 1 (13 items)
Sort Posts: Previous Next
  • 06-08-2009 8:06 AM

    • George
    • Not Ranked
    • Joined on 05-27-2009
    • Posts 9

    persistant data

    I have two questions. 

    1. is it possible to set a variable in the homepage view and then access that data in the profile view?

    2. I dont understand how to use the persistant data tutorials. I have read all of the posts and they all either point to the same code or use the same example. When I try to use the example it never works. nothing is displayed. Can somebody maybe give me an example of how to write to a variable called name with the value of "George" ? I would appriciate it very much. 

     

    Thanks in advance,

    -George

    Filed under:
  • 06-08-2009 8:11 AM In reply to

    Re: persistant data

    1. Can you give me an example of what you're trying to do specifically?

    2. Have you seen our sample apps (Demos)?

    http://wiki.developer.myspace.com/index.php?title=Category:Sample_Applications

  • 06-08-2009 8:20 AM In reply to

    • George
    • Not Ranked
    • Joined on 05-27-2009
    • Posts 9

    Re: persistant data

    yeah.

     so what I want to do is have an input field on the home view that when the submit button is pressed it stores what ever was in the field. Then on the profile view it reads the variable and (to simplify) prints it out on the screen. 

     

    and I saw the demo's but like when I C/P them into my "home-view" editor the dont do anything. 

  • 06-08-2009 9:04 AM In reply to

    Re: persistant data

    Hey, re: the field, you're talking about an empty field where the user inputs the data.. something like "what do you wat us to call you?" (enter name) and then have that display correct?

     

  • 06-08-2009 9:16 AM In reply to

    • George
    • Not Ranked
    • Joined on 05-27-2009
    • Posts 9

    Re: persistant data

     yeah. I dont really need help on designing that part but if your just seeking clarity on what I said then yes exactly.

     

    //HomeView

     [Enter Name Here] [Submit Button]

    //End Home View

     

    //Profile View

    Your Name is: (what ever you put in the Enter Name Here spot on homeview)

    //End Profile View

  • 06-08-2009 9:23 AM In reply to

    Re: persistant data

    I know that this can be done, because there are apps doing it, we don't have a code sample for it - that I am aware of. I'll look into it.

  • 06-08-2009 12:50 PM In reply to

    • George
    • Not Ranked
    • Joined on 05-27-2009
    • Posts 9

    Re: persistant data

         <script type="text/javascript">
    var req = opensocial.newDataRequest();
    req.add(
        req.newUpdatePersonAppDataRequest("VIEWER", "myKey", "myValue"),
        "set_data");
    req.send(set_callback);

    function set_callback(response) {
      if (response.get("set_data").hadError()) {
        /* The update failed ... insert code to handle the error */
    document.write("failed");

      } else {
        /* The update was successful ... continue execution */
    Document.write("completed");
      }
    };
    </script>

     

    why does this return "failed" ? It is a direct copy of the example used on the open social wiki... 

  • 06-08-2009 1:22 PM In reply to

    Re: persistant data

    Teacher's pet source

    Canvas

    Profile

    Home

  • 06-09-2009 8:19 AM In reply to

    • George
    • Not Ranked
    • Joined on 05-27-2009
    • Posts 9

    Re: persistant data

     1. Clicking on those requires a www.fegmail.com username and password( dont know if its supposed to be that way or not)

     2. After looking at the source of teachers pet it still does not explain what I am asking about. 

     

    var req = opensocial.newDataRequest();

    req.add(req.newUpdatePersonAppDataRequest("VIEWER", "pet1", tempPet));
    req.add(req.newUpdatePersonAppDataRequest("VIEWER", "pet2", p1));
    req.add(req.newUpdatePersonAppDataRequest("VIEWER", "pet3", p2));
    req.add(req.newUpdatePersonAppDataRequest("VIEWER", "pet4", p3));
    req.add(req.newUpdatePersonAppDataRequest("VIEWER", "pet5", p4));

    req.send();
    }
    Is the code used in the teachers pet canvas soucre to add data
     
    it seems to work. However when I try to replicate that with:
     
    var req = opensocial.newDataRequest();
    req.add(
    req.newUpdatePersonAppDataRequest("VIEWER", "myKey", "myValue"),"set_data");
    req.send(set_callback);

    function set_callback(response) {
    if (response.get("set_data").hadError()) {
    /* The update failed ... insert code to handle the error */
    document.write("failed");

    } else {
    /* The update was successful ... continue execution */
    Document.write("completed");
    }
    };
     
     
     that does nothing.
     
     

     

  • 06-09-2009 9:21 AM In reply to

    Re: persistant data

     You can view the source of the file by clicking on the app canvas, open the frame in a new window   and view the source code. 

    Rhonda

  • 06-09-2009 9:56 AM In reply to

    • George
    • Not Ranked
    • Joined on 05-27-2009
    • Posts 9

    Re: persistant data

     ok. I included a bit of code from the source file in my previous post. However if I try to use that same technique in my code it doesn't work in the same manor. I was wondering if anyone knew why? or if they could just give me a working example of how to store a variable. I have tried using the one on the opensocial wiki, the one in the myspace app docs, and now the one from the source code of the teachers pet app but I cant seem to replicate them. 

  • 06-09-2009 11:19 AM In reply to

    Re: persistant data

    Can you please send me your entire code?

    Rhonda

     

  • 06-09-2009 11:22 AM In reply to

    Re: persistant data

    use pastebin.com

Page 1 of 1 (13 items)