Documentation - Profiles
How to search for and retrieve an individuals profiles from across the web.
The Identi Engine has the ability to retrieve a collection of profiles from an individual's distributed identity across the web. It stores this information in a collection called ident.profiles. See demo: Profile Discovery
1. Creating a search
var doc = jQuery(document);
doc.ready(function () {
ident.useInwardEdges = true;
doc.bind('ident:update', renderProfile);
ident.search('http://twitter.com/glennjones');
});
The code snippet above is using jQuery to create a function which executes as soon as the HTML document is loaded.
Properties
- useInwardEdges
- The useInwardEdges property controls how the identities are found. If it is set to true it will return a larger sets of results, but there is a greater chance that Identi Engine will return the wrong information about an individual. There will be less of a chance of error if the property is set to false. By default this property is set to true.
Binding the rendering function
The Identi Engine will update the identities collection a number of times during a single search. To capture the updates we need to bind our own rendering function to the events fired by the library. This can be done easily with jQuery for example:
doc.bind('identi:update', renderProfile);
The code above will call the function renderProfile every time the Identi Engine updates it profiles collection.
2. Rendering results
function renderProfile(e){
jQuery('#profiles').html('');
ident.profiles.sort(ident.sortByDomain);
for (var i = 0; i < ident.profiles.length; i++) {
var hCard = ident.profiles[i];
var div = jQuery('<div class="profile"></div>').appendTo('#profiles');
jQuery('<div class="fn">' + hCard.fn + '</div>').appendTo(div);
if( hCard.title )
if(hCard.title.length > 0 )
jQuery('<div class="title">' + hCard.title[0].value + '</div>').appendTo(div);
...
}
Please read the page profile structure for a complete overview of the data returned in the ident.profiles collection.
The files that need to be included in the page
There are four files you must include in your HTML for the Identi Engine to create the profiles collection.
jquery-1.3.2.min.js identi-0.1.js identi-profile-0.1.js identi-yql-parser-0.1.js
Alternatively, you can swap the parser to UfXtract which in some cases will return more results. The UfXtract parser should only be used for low traffic situations.
jquery-1.3.2.min.js identi-0.1.js identi-profile-0.1.js identi-ufxtract-parser-0.1.js
Issues with Twitter profile
The current hCard mark up of Twitter profiles has slowly degraded through a number of redesigns. To fix this one site there is a temporary hack which uses the YQL XPath instead of a microformats parser. To use this hack all you need to do is include the file: identi-twitter-parser-0.1.js. It will automatically override the other parsers when a request is made for a Twitter profile.
jquery-1.3.2.min.js identi-0.1.js identi-profile-0.1.js identi-yql-parser-0.1.js identi-twitter-parser-0.1.js
