Hi guys i am new to opensocial . i am working with the example given
in the java library. I just cant figure out why i dont get anyother
info other than name or gender even though i have set many other
fields in my profile. Please have a look at my code below and let me
know .
public static void main(String[] args) {
// Create a new OpenSocialClient instance configured to hit orkut
endpoints;
// other pre-configured providers include MYSPACE, GOOGLE, and
PLAXO
OpenSocialClient c =
new OpenSocialClient(OpenSocialProvider.valueOf
("ORKUT_SANDBOX"));
c.setProperty(OpenSocialClient.Property.DEBUG, "true");
if (args.length > 0 && args[0].equalsIgnoreCase("REST")) {
c.setProperty(OpenSocialClient.Property.RPC_ENDPOINT, null);
}
// Credentials provided here are associated with the gadget
located at
//
http://opensocial-resources.googlecode.com/svn/samples/rest_rpc/sample.xml;
// If you install this gadget, you can substitute your own
OpenSocial ID
// for the one used below and fetch your profile data and friends
c.setProperty(OpenSocialClient.Property.CONSUMER_SECRET,
"watever");
c.setProperty(OpenSocialClient.Property.CONSUMER_KEY,
"watever");
c.setProperty(OpenSocialClient.Property.VIEWER_ID,
"123");
try {
// Create a new OpenSocialRequestParameterSet object to indicate
which request
// parameters you want to pass with your request; in this case,
we are asking
// orkut specifically to return the name and gender fields for
the person
// fetched below.
Map<String, OpenSocialRequestParameter> params =
new HashMap<String, OpenSocialRequestParameter>();
params.put("fields", new OpenSocialRequestParameter(new String[]
{"religion", "name","gender",}));
// Retrieve the profile data of the specified user using the
OpenSocialClient
// method fetchPerson; pass in the parameter set object created
above
OpenSocialPerson person = c.fetchPerson("123", params);
System.out.println("----------");
// Output the name, ID, and gender of the requested person
System.out.println("ID: " + person.getId());
System.out.println("Name: " + person.getDisplayName());
System.out.println("Gender: " + person.getField
("gender").getStringValue());
// --------not working---------giving null exception//
System.out.println("Country:"+person.getField
("religion").getStringValue());
System.out.println("----------");
} catch (org.opensocial.client.OpenSocialRequestException e) {
System.out.println("OpenSocialRequestException thrown: " +
e.getMessage());
e.printStackTrace();
} catch (java.io.IOException e) {
System.out.println("IOException thrown: " + e.getMessage());
e.printStackTrace();
}
}
}
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Orkut Developer Forum" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/opensocial-orkut?hl=en
-~----------~----~----~----~------~----~------~--~---