Hi,
I am very new to opensocial (Orkut) and trying to access the basic
services provided by open social .net APIs to access inbasic
information from orkut.
I am getting 401 error every time i am sending a request to orkut
sandbox. Below is the code for the same. Please help me in finding the
reason.
using System;
using org.opensocial.client;
using org.opensocial.data;
public partial class _Default : System.Web.UI.Page
{
public class User
{
public User(string Id, string AlbumId, string MediaItemId,
string AppId)
{
this.Id = Id;
this.AlbumId = AlbumId;
this.MediaItemId = MediaItemId;
this.AppId = AppId;
}
public string Id;
public string AlbumId;
public string MediaItemId;
public string AppId;
}
protected void Page_Load(object sender, EventArgs e)
{
string strUserName = "DummyUser";
string strSecretKey = "SecretKey";
string strCustomerkey = "CustomerKey";
User user = new User(strUserName, null, null, null);
OpenSocialClient client = new OpenSocialClient("orkut.com");
client.setProperty(OpenSocialClient.Properties.REST_BASE_URI,
"http://sandbox.orkut.com/social/rest");//http://www.orkut.com/social/
rest | http://sandbox.orkut.com/social/rest
client.setProperty
(OpenSocialClient.Properties.CONSUMER_SECRET, strSecretKey);
client.setProperty(OpenSocialClient.Properties.CONSUMER_KEY,
strCustomerkey);
client.setProperty(OpenSocialClient.Properties.VIEWER_ID,
strUserName);
try
{
FetchMe(client);
}
catch (Exception ex)
{
Response.Write("Yatin2 " + ex.Message);
}
}
// fetches the default parameters for the viewer (@me)
private void FetchMe(OpenSocialClient client)
{
// request the person object
Person person = client.fetchPerson();
// output the result to the screen
OutputPerson(person);
}
private void OutputPerson(Person person)
{
Response.Write("----------<br>");
// Output the name, ID, and gender of the requested person
Response.Write("ID: " + person.Id + "<br>");
Response.Write("Name: " + person.DisplayName + "<br>");
Response.Write("Profile Url: " + person.ProfileUrl + "<br>");
Response.Write("<img src='" + person.ThumbnailUrl + "' /
><br>");
Response.Write("Is Owner: " + person.IsOwner + "<br>");
Response.Write("Is Viewer: " + person.IsViewer + "<br>");
Response.Write("Has App: " + person.HasApp + "<br>");
Response.Write("Updated: " + person.Updated.ToString() +
"<br>");
OutputAddress(person.CurrentLocation);
CheckNullAndOutput(person, "gender");
CheckNullAndOutput(person, "aboutMe");
}
private void OutputAddress(Address address)
{
if (null == address) return;
Response.Write("Current Location:<br>");
Response.Write(" * Country:"
+ address.Country + "<br>");
Response.Write
(" * ExtendedAddress:" +
address.ExtendedAddress + "<br>");
Response.Write
(" * Formatted:" + address.Formatted
+ "<br>");
Response.Write
(" * Latitude:" + address.Latitude +
"<br>");
Response.Write
(" * Locality:" + address.Locality +
"<br>");
Response.Write
(" * Longitude:" + address.Longitude
+ "<br>");
Response.Write(" * PoBox:" +
address.PoBox + "<br>");
Response.Write
(" * PostalCode:" +
address.PostalCode + "<br>");
Response.Write(" * Primary:"
+ address.Primary + "<br>");
Response.Write(" * Region:"
+ address.Region + "<br>");
Response.Write
(" * StreetAddress:" +
address.StreetAddress + "<br>");
Response.Write(" * Type:" +
address.Type + "<br>");
}
private void CheckNullAndOutput(Person person, string field)
{
if (null != person.getField(field))
{
Response.Write(field + ": " + person.getField
(field).StringValue + "<br>");
}
}
}
Thanks,
Yatin
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---