elsewhere
Version:
A node project that aims to replicate the functionality of the Google Social Graph API
28 lines (18 loc) • 2.06 kB
HTML
<p>The <code>elsewhere.graph()</code> method accepts the following parameters:</p>
<p><strong>url</strong> This is the URL that you wish to graph. The assumption is that it represents a person (or a company or organisation) and that the page at that URL has <code>rel=me</code> links to other URLs that also represent the person.</p>
<p><strong>options</strong> (optional) This object contains properties used to configure the graph. The properties that can be passed in are: <code>strict</code>, <code>logLevel</code>, <code>crawlLimit</code>, <code>domainLimit</code>, <code>stripDeeperLinks</code>, <code>useCache</code>, <code>cacheTimeLimit</code> and <code>cacheItemLimit</code>. These are the same options that can be set in the global configuration (see below).</p>
<p><strong>callback</strong> (optional) This is a function to be called once the graph is ready. The callback is passed an error (string or null) and the completed graph as a object literal.</p>
<p>The method returns a <a href='http://wiki.commonjs.org/wiki/Promises'>promise</a> object (created by the <a href='https://npmjs.org/package/underscore.deferred'>Underscore.deferred</a> module). This is an alternative to using the <code>callback</code> parameter and provides fine-grained flow control.</p>
<p>Some examples of valid calls to the <code>graph()</code> method:</p>
<pre><code>var options = {strict:true},
callback = function (err, graph) {
if (err) {
console.log(graph);
} else {
console.log(JSON.stringify(graph));
}
};
elsewhere.graph('http://premasagar.com', options, callback);
elsewhere.graph('http://chrisnewtn.com', callback);
elsewhere.graph('http://glennjones.net').then(callback);</code></pre>
<p>If an error happens trying to parse the starting point URL, the returning ‘err’ object will contain a string message of the error. The ‘graph’ object will still be returned. Any after during the parsing of additional URLs will be added to the warnings collection, part of the graph object.</p>