MySpace Developer Platform

A Place For Developers

Welcome Developers!

in

Welcome!

in

userType in JavaScript

Last post 06-06-2008 3:59 PM by mNeo. 10 replies.
Page 1 of 1 (11 items)
Sort Posts: Previous Next
  • 03-11-2008 1:56 AM

    userType in JavaScript

    Hi. As you know,  people and app are friends (thank to MySpace :))

    Well, when my app recieves a  VIEWER_FRIENDS list,

    I would like to distingiush  apps and people.
    In API requests each user's node has field userType. For people value is 'RegularUser'

    Unfortunately, neither MySpace, nor OpenSocial namespaces declared a field 'userType'

      var viewerData = dataResponse.get(opensocial.DataRequest.PersonId.VIEWER).getData();
      var viewerName = viewerData.getField(opensocial.Person.Field.NAME);
      alert(viewerData.getField('userType'));


       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      How do I get that info field ?

  • 03-11-2008 3:17 AM In reply to

    Re: userType in JavaScript

     I get

    <usertype>RegularUser</usertype>

    <usertype>Band</usertype>

    <usertype>Application</usertype>

     from the Flash API

    Is it case sensitive as your example has a big T?

    Valery Filin:
    userType
     

    Eddie 

     

  • 03-11-2008 5:21 AM In reply to

    Re: userType in JavaScript

    Eddie, yes, i mention these fileds

    As we can see, there are "userType": "RegularUser" and "userType": "Application". The JSON dump is below.

    In JavaScript I tried both variants:

     var personFields = new Array(
          opensocial.Person.Field.ID,
        'userType',   
        'usertype'

      );

      var param = {};
      param[opensocial.DataRequest.PeopleRequestFields.PROFILE_DETAILS] = personFields;
      var viewerFriendsReq = os.newFetchPeopleRequest(opensocial.DataRequest.Group.VIEWER_FRIENDS,param);
      dataReqObj.add(viewerFriendsReq);

    However  my sample returned only an undefined value:
      var viewerData = dataResponse.get(opensocial.DataRequest.PersonId.VIEWER).getData();
      alert(viewerData.getField('usertype'));

    RequestURI: http://api.msappspace.com/v1/users/248545017/friends.json


    {
        "count": 5,
        "friends": [
            {
                "__type": "User:#MySpace.Services.DataContracts",
                "image": "http://x.myspacecdn.com/images/no_pic.gif",
                "largeimage": "http://x.myspacecdn.com/images/no_pic.gif",
                "name": "ryan",
                "uri": "http://api.msappspace.com/v1/users/30756034",
                "userId": 30756034,
                "userType": "RegularUser",
                "webUri": "http://www.myspace.com/30756034"
            },
            {
                "__type": "User:#MySpace.Services.DataContracts",
                "image": "http://b1.ac-images.myspacecdn.com/01234/11/76/1234286711_s.jpg",
                "largeimage": "http://b1.ac-images.myspacecdn.com/01234/11/76/1234286711_l.jpg",
                "name": "unterhund",
                "uri": "http://api.msappspace.com/v1/users/81368369",
                "userId": 81368369,
                "userType": "RegularUser",
                "webUri": "http://www.myspace.com/underdogvsunderdog"
            },
            {
                "__type": "User:#MySpace.Services.DataContracts",
                "image": "http://x.myspacecdn.com/images/no_pic.gif",
                "largeimage": "http://x.myspacecdn.com/images/no_pic.gif",
                "name": "Disease",
                "uri": "http://api.msappspace.com/v1/users/343094351",
                "userId": 343094351,
                "userType": "Application",
                "webUri": "http://www.myspace.com/diseasespace"
            },
            {
                "__type": "User:#MySpace.Services.DataContracts",
                "image": "http://x.myspacecdn.com/images/no_pic.gif",
                "largeimage": "http://x.myspacecdn.com/images/no_pic.gif",
                "name": "EntityTestApp",
                "uri": "http://api.msappspace.com/v1/users/343853774",
                "userId": 343853774,
                "userType": "Application",
                "webUri": "http://www.myspace.com/343853774"
            },
            {
                "__type": "User:#MySpace.Services.DataContracts",
                "image": "http://x.myspacecdn.com/images/no_pic.gif",
                "largeimage": "http://x.myspacecdn.com/images/no_pic.gif",
                "name": "Diseaser",
                "uri": "http://api.msappspace.com/v1/users/343960053",
                "userId": 343960053,
                "userType": "Application",
                "webUri": "http://www.myspace.com/343960053"
            }
        ],
        "next": null,
        "prev": null,
        "topFriends": "http://api.msappspace.com/v1/users/248545017/friends?list=top",
        "user": {
            "__type": "User:#MySpace.Services.DataContracts",
            "image": "http://x.myspacecdn.com/images/no_pic.gif",
            "largeimage": "http://x.myspacecdn.com/images/no_pic.gif",
            "name": "Valery Filin",
            "uri": "http://api.msappspace.com/v1/users/248545017",
            "userId": 248545017,
            "userType": "RegularUser",
            "webUri": "http://www.myspace.com/vfilin"
        }
    }

  • 04-04-2008 10:21 AM In reply to

    • John
    • Top 75 Contributor
    • Joined on 02-27-2008
    • Posts 36

    Re: userType in JavaScript

    Why is this problem still happening? We've had the userType field sent to the app for more than 3 weeks now, but we still cannot access this field programmatically! This should be a very high priority fix because it gives the applications a lot of useful information about friends and its not difficult to fix.

    In particular, the MyOpenSpace.DataMapper_.prototype.mapFriends_ method needs to add the userType to the person object. That's all!

  • 04-04-2008 12:27 PM In reply to

    Re: userType in JavaScript

    Ha, mainly because I couldn't figure out which function to add the code to until now :P

    Seriously though, just didn't see the thread, I've made the change.

  • 04-04-2008 2:56 PM In reply to

    • John
    • Top 75 Contributor
    • Joined on 02-27-2008
    • Posts 36

    Re: userType in JavaScript

    Chad:
    I've made the change.
    Great, do you know when the prod server will be updated? Tuesday after next?
  • 04-07-2008 12:00 PM In reply to

    Re: userType in JavaScript

    Yep, thereabouts. 

  • 06-03-2008 1:58 PM In reply to

    • mNeo
    • Top 25 Contributor
    • Joined on 02-05-2008
    • Posts 108

    Re: userType in JavaScript

    And is this how to access it (Copying the code from above)?

    In Request method: 

     var personFields = new Array(
          opensocial.Person.Field.ID,
        'userType'
      );

      var param = {};
      param[opensocial.DataRequest.PeopleRequestFields.PROFILE_DETAILS] = personFields;
      var viewerReq = os.newFetchPeopleRequest(opensocial.DataRequest.Group.VIEWER,param);
      dataReqObj.add(viewerReq);

    In Callback method:


      var viewerData = dataResponse.get(opensocial.DataRequest.PersonId.VIEWER).getData();
      alert(viewerData.getField('userType'));

  • 06-06-2008 2:22 PM In reply to

    • mNeo
    • Top 25 Contributor
    • Joined on 02-05-2008
    • Posts 108

    Re: userType in JavaScript

     bump

  • 06-06-2008 2:27 PM In reply to

    • Sumit
    • Not Ranked
    • Joined on 04-11-2008
    • Posts 5

    Re: userType in JavaScript

     this thing does not work....

    and i want to get the user type for the owner (or viewer) only and not owner's( or viewer's) friends

    it does not work  ...

  • 06-06-2008 3:59 PM In reply to

    • mNeo
    • Top 25 Contributor
    • Joined on 02-05-2008
    • Posts 108

    Re: userType in JavaScript

     Chad (or someone else from MDP), can you please provide us some pointers for this.

Page 1 of 1 (11 items)