views:

98

answers:

1

I want to store the Person.Field.ID number of a logged-in person in a .aspx .net variable so that I can use it in a VB script. I am using the sign-in gadget on my site. How do I do this?

+1  A: 

Check out the .NET OpenSocial client library and the C# port of the Chow Down. These would be two alternate methods for pulling in the GFC ID of the current viewer in .NET, though you'd probably have to translate the latter from C# to VB.NET if you wanted to use it, since it's not a shared library. Unfortunately, I don't think the client library was written with Friend Connect in mind, so the simpler fcauth method probably isn't available. You'll have to go through the 2-legged OAuth process. I assume the client library supports this, since it's a port of the Java version, which does.

If all that sounds too complicated, and all you really need is the ID, you might just pass it back with a simple Ajax/XHR call. Here's the JS API call for getting the ID:

var req = opensocial.newDataRequest();
req.add(req.newFetchPersonRequest('VIEWER'), 'viewer');
req.send(function(response) {
  var data = response.get('viewer').getData();
  if (data) {
    visitorId = data.getId();
    // Send the ID to your server via Ajax/XHR here
  } else {
    // Not logged in
    visitorId = null;
  }
});

Update: You may also be interested in the project that Brian Clifton just released: friendconnect-dotnet

Bob Aman