MySpace Developer Platform

A Place For Developers

Welcome Developers!

in

Welcome!

in

Having problems with "OWNER" data

Last post 05-14-2008 2:20 PM by o1©. 2 replies.
Page 1 of 1 (3 items)
Sort Posts: Previous Next
  • 05-11-2008 1:47 AM

    • o1©
    • Top 500 Contributor
    • Joined on 04-24-2008
    • Posts 12

    Having problems with "OWNER" data

    I'm trying to save a custom field that appears in the canvas view, then is utilized in the profile view.  I've tried to do this a couple ways and can't seem to nail it.  I did have some data writing succesfully but only when I used the "VIEWER" special ID.

    Here's an example of the latest attempt:

    function write1() {
        var ownerreq = opensocial.newDataRequest();
        ownerreq.add(ownerreq.newFetchPersonRequest(opensocial.DataRequest.PersonId.OWNER), 'owner_id');
        ownerreq.send(write2);
    }

    function write2(response) {
        var temp = response.get('owner_id');
        var ownerID = temp.getData().getId();
       
        var req = opensocial.newDataRequest();
        req.add(req.newUpdatePersonAppDataRequest(ownerID, "url", feedUrlField.value ));
        req.send(write3);
    }

    function write3(response) {
        if(response.hadError()) {
            statusField.innerHTML = "Error updating data... " + response.getError();
        } else {
            statusField.innerHTML = "Data Saved...<br>";
        }
    }

    function read1() {
        var ownerreq = opensocial.newDataRequest();
        ownerreq.add(ownerreq.newFetchPersonRequest(opensocial.DataRequest.PersonId.OWNER), 'owner_id');
        ownerreq.send(read2);
    }
    function read2(response) {   
        var temp = response.get('owner_id');
        var ownerID = temp.getData().getId();

        var req = opensocial.newDataRequest();
        var fields = [ "url" ];
        req.add(req.newFetchPersonAppDataRequest(ownerID, fields), "owner_data");
        req.send(readDataFetch);
    }

    function read3(response) {
        var mydata = response.get("owner_data");

        data = mydata.getData();

        for(var key in data) {
            for (var key2 in data[key]) {
                alert(data[key][key2]
            }
        }
    }
     Please any help?? 
    Filed under:
  • 05-13-2008 6:40 AM In reply to

    Re: Having problems with "OWNER" data

    As per OpenSocial specs, only VIEWER can be updated -- to update OWNER, you'd update VIEWER data when OWNER and VIEWER are the same user. You also don't have to go through the extra step of retrieving the UserId to do a data update (I assume you're doing that because updates to opensocial.[..].OWNER don't work?), just use the VIEWER constant.

    By default, only the App's OWNER has access to the Canvas, so you can be pretty sure that OWNER and VIEWER are the same there. The other surface where it's pretty much a given they'll be the same is Home. Otherwise, just check that they're the same (the safest bet is to fetch both, and compare Ids).

  • 05-14-2008 2:20 PM In reply to

    • o1©
    • Top 500 Contributor
    • Joined on 04-24-2008
    • Posts 12

    Re: Having problems with "OWNER" data

    Cool I think I got it all working... Seems like my issue now is saving URLs with ampersands :)
Page 1 of 1 (3 items)