Acquiring user profile information and Mobatomo (Friend) information

Acquiring user profiles

The code for acquiring a user (Viewer) profile using an application is as follows:

  • Call opensocial.newDataRequest() and create a DataRequest.
  • Call newFetchPersonRequest() in the generated DataRequest and generate a request.
  • Call newFetchPersonRequest() in the generated DataRequest and generate a request.
  • Call DataRequest.send(callback) and make a request to acquire information.
  • Once the server request process is complete, the callback function specified with send() is executed using the DataResponse that contains the request results as an argument.
  • Process the data that is stored in DataResponse.

In addition, the following information can be acquired when the newFetchPersonRequest() method is executed without specifying the params argument:

  • User ID
  • Nickname
  • URL of the avatar in the profile

Acquiring a more detailed profile

The code for acquiring a more detailed profile is as follows:

  • Using opensocial.DataRequest.PeopleRequestFields.PROFILE_DETAILS as a key, specify an array for the information you want to acquire.
  • Assign this params object as the second argument in newFetchPersonRequest().

The following information can be specified in PROFILE_DETAILS:

  • opensocial.Person.Field.ID - User ID
  • opensocial.Person.Field.NICKNAME - Nickname
  • opensocial.Person.Field.PROFILE_URL - URL of the profile page
  • opensocial.Person.Field.THUMBNAIL_URL - URL of the avatar in the profile
  • opensocial.Person.Field.ABOUT_ME - Personal introduction
  • opensocial.Person.Field.ADDRESS - Location (prefecture only)
  • opensocial.Person.Field.AGE - Age
  • opensocial.Person.Field.DATE_OF_BIRTH - Date of birth
  • opensocial.Person.Field.INTERESTS - Interests
  • opensocial.Person.Field.HAS_APP - Whether or not an application has been installed
  • mbga.Person.Field.JOB_TYPE - Occupation
  • mbga.Person.Field.BLOOD_TYPE - Blood type

If the user has refused to disclose any of the above information, such information cannot be retrieved.

Acquiring information on the list of Mobatomo (Friends)

The code for acquiring information on the Mobatomo (Friends) of the viewer is as follows:

  • Specify the user who will be the target of opensocial.IdSpec.Field.USER_ID.
  • Specify the relationship of the user who will be the target of opensocial.IdSpec.Field.GROUP_ID. This value will always be opensocial.IdSpec.GroupId.FRIENDS.
  • Make these arguments and call opensocial.newIdSpec() to generate an IdSpec.
  • Call opensocial.newDataRequest() and create a DataRequest.
  • Make the newly generated IdSpec an argument, and call newFetchPeopleRequest() to generate a request.
  • Call DataRequest.add(request) and register the request.
  • Call DataRequest.send(callback) and make a request to acquire information.
  • Once the server request process is complete, the callback function specified with send() is executed using the DataResponse that contains the request results as an argument.
  • Since DataResponse contains opensocial.Collection objects, information on each Mobatomo (Friend) is acquired by calling each().

By default, the number of Collections returned by newFetchPeopleRequest() is 50.
A specific number of cases can be selected by including opensocial.DataRequest.PeopleRequestFields.MAX in the parameter. The maximum value is 1,000.

Revision History

  • 12/2010
    • Initial Release.

PREVIOUS

HelloWorld!

NEXT

Sending Activities