Documentation - Identities
How to search across people's identities and build lists of their online accounts.
Given a profile URL of an individual, the Identi Engine can collect a list of social media site accounts related to that person. It stores this information in a collection called ident.identities. See demo: Identity discovery
1. Creating a search
var doc = jQuery(document);
doc.ready(function () {
ident.useInwardEdges = true;
ident.iconPath = "identi/icons/";
ident.addPrimaryURL = 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. Within the function call we set a number of search properties.
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.
- iconPath
- The iconPath property is a string which is added in front of the icon file name. It allows you to modify the iconUrl path information in the results.
- addPrimaryURL
- The addPrimaryURL property determines whether the result set should start with the URL most commonly associated with the individual. This is often a blog URL. 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('ident:update', renderProfile);
The code above will cause the function called renderProfile to be fired every time the Identi Engine updates it's identities collection.
2. Rendering results
function renderProfile(e){
jQuery('#identities').html('');
if(ident.identities.length > 0){
var ul = jQuery('<ul class="profile-list"></ul>').appendTo('#identities');
for (var x = 0; x < ident.identities.length; x++) {
if(ident.identities[x].name != '')
jQuery('<li>
<a href="' + ident.identities[x].profileUrl + '">
<img width="16" class="icon" src="' + ident.identities[x].iconUrl + '" />'
+ ident.identities[x].name + '</a> <span class="username">(' +
ident.identities[x].username + ')</span>
</li>').appendTo(ul);
else
jQuery('<li>
<a href="' + ident.identities[x].profileUrl + '">
<img width="16" class="icon" src="' + ident.identities[x].iconUrl + '" />'
+ ident.identities[x].domain + '</a></li>').appendTo(ul);
}
}
}
The renderProfile function uses jQuery to create a list of accounts in a HTML element with the ID identities. It simply loops through the collection creating the <li> list item from the properties listed above. It checks to see if the account has a name property to decide how it will render the list item.
Please read the page ident.identities data structure for a complete overview of the data returned by this search
The files that need to be included in the page
There are two files you must include in your HTML for the Identi Engine to create the identities collection.
jquery-1.3.2.min.js identi-0.1.js
You can then enhance your results by adding two more files. Including the identi-profile-0.1.js file will automatically upgrade the search feature without having to add any extra code. With this file present the search feature will parse each profile page it finds for extra information. Although it may return a more complete set of results it is slower due to the additional API calls made. The identi-profile-0.1.js file needs one of the two parsers. In the example below we are using the YQL parser.
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
