<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Claudio&#039;s Hideout &#187; google</title>
	<atom:link href="http://claudio.cicali.name/post/tag/google/feed/" rel="self" type="application/rss+xml" />
	<link>http://claudio.cicali.name</link>
	<description>Claudio Cicali web hub</description>
	<lastBuildDate>Sun, 25 Sep 2011 11:29:05 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>Using «Federated Login for Google Account Users» in your application</title>
		<link>http://claudio.cicali.name/post/2010/11/using-%c2%abfederated-login-for-google-account-users%c2%bb-in-your-application/</link>
		<comments>http://claudio.cicali.name/post/2010/11/using-%c2%abfederated-login-for-google-account-users%c2%bb-in-your-application/#comments</comments>
		<pubDate>Mon, 29 Nov 2010 09:31:14 +0000</pubDate>
		<dc:creator>claudio</dc:creator>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[Programmazione]]></category>
		<category><![CDATA[google]]></category>
		<category><![CDATA[integration]]></category>
		<category><![CDATA[login]]></category>
		<category><![CDATA[openid]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://claudio.cicali.name/?p=949</guid>
		<description><![CDATA[I recently had to add an authentication system to an application of mine. Another login, another password checking, another&#8230; Boooring. Given the nature of the application I decided that this time I could cut the mess down and go only with the «Use your Google account» &#8220;one click&#8221; login. Why not? Lot of people have an [...]]]></description>
			<content:encoded><![CDATA[<p>I recently had to add an authentication system to an application of mine.</p>
<p>Another login, another password checking, another&#8230; Boooring. Given the nature of the application I decided that this time I could cut the mess down and go only with the «Use your Google account» &#8220;one click&#8221; login. Why not? Lot of people have an google account already and <strong>it&#8217;s OpenID</strong>!</p>
<p>The usual Google documentation page <a href="http://code.google.com/apis/accounts/docs/OpenID.html">is this one</a>. The good news is that if you follow this guide you probably will not need to read that whole page :) Later on you should integrate this very document with the Google one.</p>
<p>The first thing to know is that you are going to write an <a href="http://openid.net/">OpenID</a> client/consumer. OpenID 2 protocol is indeed the system behind the whole client/server scenario from your application (the client) and the Google accounting system (the server). I have to assume that you know what that means (at an high level, at least). The examples here are in <strong>PHP</strong> and below I will provide some sample code for you to play with.</p>
<p>OK; so here are the relevant points:</p>
<ul>
<li>This one is theoretical, but it&#8217;s how Google deployed the OpenID protocol on top of his already existing authentication system. Normally, in a &#8220;pure&#8221; OpenID environment, during the login process the user will give you his/her openid identifier (an URL); using that identifier your program will discover (via the Yadis protocol) which is the corresponding server party to talk to for the authentication process. In the Google scenario you don&#8217;t know which is the user&#8217;s OpenID identifier (the user, of course, is not even aware that there&#8217;s something like &#8220;openid&#8221; involved in the way s/he logs in). You have NOT to ask her for her &#8220;google account&#8221;; you have to make him press a button or follow a link to &#8220;Login with your Google account&#8221;. But you DO know who you have to ask for protocol informations and not have to infer it from the user&#8217;s OpenID (technically, a discovery process is needed anyway). Upon a succesfull login you WILL have the user&#8217;s OpenID identifier; it&#8217;s something like a generated string, not choosen by the user and crafted by Google itself.</li>
<li>You need a recent OpenID library that supports OpenID 2.0 XRI and Yadis discovery. This <strong>excludes</strong> (as for now) the Zend Framework OpenID component (it does support OpenID 2.0, but not the discovery part in the version Google uses). Too bad. You then need to go straight to the <a href="http://www.janrain.com/openid-enabled">JanRain library</a></li>
<li>Don&#8217;t bother thinking about Simple Registration (SREG): Google does support the more advanced (and useful) Attribute Exchange (AX) extension only</li>
<li>Speaking of profile data, there is nothing much you can get: email, name and surname. I noticed that unless you specify each one as <em>mandatory</em> (within the AX request), the user is not even asked &#8211; by Google &#8211; to give them to you. There&#8217;s probably somethng I misunderstood, but this is it.</li>
</ul>
<p>On your side, the login process will consist of two distint phases: one that <strong>initiates</strong> the login process the and one that <strong>finalizes</strong> it.</p>
<p>Normally you point your &#8220;Login with Google&#8230;&#8221; link to the script that implements the initiation phase (let&#8217;s say &#8220;login.php&#8221;). The finalize script (let&#8217;s say &#8220;finalize.php&#8221;) will be called by the Google server as per protocol. There is a lot more to know about the OpenID process, of course, but the library should hide the gory details for you.</p>
<p>The login script will immediately and trasparently forward the user to the real Google account login page. The finalize script will have the logic that checks if the authentication has been succesfull or not and act consequently.</p>
<p>I&#8217;m about to show you some code, but keep in mind that <strong>this is NOT </strong>valid PHP code; I want you to understand what&#8217;s going on rather than being able to just copy/paste. To further limit clutter I did not even add basic error checking. Please check the JanRain library examples for full fledged (and working) code.</p>
<p>So, for the login process:</p>
<pre class="brush: php; title: ; wrap-lines: false; notranslate">
# Requires the needed JanRain scripts
require_once &quot;Auth/OpenID/Consumer.php&quot;;
require_once &quot;Auth/OpenID/FileStore.php&quot;;
require_once &quot;Auth/OpenID/AX.php&quot;;

# Setup the library (leaved blank on purpose).
# Will also create the $store variable used below
...

$consumer = new Auth_OpenID_Consumer($store);

$auth_request = $consumer-&gt;begin(&quot;https://www.google.com/accounts/o8/id&quot;);

# Create attribute request object (this is where you prepare the Attribute Exchange request)
$attribute = array();
$attribute[] = Auth_OpenID_AX_AttrInfo::make('http://axschema.org/contact/email', 2, true, 'email');
$attribute[] = Auth_OpenID_AX_AttrInfo::make('http://axschema.org/namePerson/first', 1, false, 'firstname');
$attribute[] = Auth_OpenID_AX_AttrInfo::make('http://axschema.org/namePerson/last', 1, false, 'lastname');

# Create AX fetch request
$ax = new Auth_OpenID_AX_FetchRequest();

# Add attributes to AX fetch request
foreach($attribute as $attr){
  $ax-&gt;add($attr);
}

$auth_request-&gt;addExtension($ax);

$return_to = sprintf(&quot;http://%s:%s%s/finalize.php&quot;, $_SERVER['SERVER_NAME'], $_SERVER['SERVER_PORT'], dirname($_SERVER['PHP_SELF']));
$trust_root = sprintf(&quot;http://%s:%s%s/&quot;, $_SERVER['SERVER_NAME'], $_SERVER['SERVER_PORT'], dirname($_SERVER['PHP_SELF']));

$form_html = $auth_request-&gt;htmlMarkup($trust_root, $return_to, false, array('id' =&gt; 'openid_message'));

# This will actually redirect to Google
print $form_html;
</pre>
<p>This is what I have in my finalize.php script:</p>
<pre class="brush: php; title: ; wrap-lines: false; notranslate">
# Requires the needed JanRain scripts
require_once &quot;Auth/OpenID/Consumer.php&quot;;
require_once &quot;Auth/OpenID/FileStore.php&quot;;
require_once &quot;Auth/OpenID/AX.php&quot;;

# Setup the library (leaved blank on purpose).
# Will also create the $store variable used below
...

$consumer = new Auth_OpenID_Consumer($store);

$return_to = sprintf(&quot;http://%s:%s%s/finalize.php&quot;, $_SERVER['SERVER_NAME'], $_SERVER['SERVER_PORT'], dirname($_SERVER['PHP_SELF']));
$response = $consumer-&gt;complete($return_to);

$msg = '';

switch($response-&gt;status) {

  case Auth_OpenID_CANCEL:
    # This means the authentication was cancelled by the user
    $msg = 'Verification cancelled.';
    break;

  case Auth_OpenID_FAILURE:
    $msg = &quot;OpenID authentication failed: &quot; . $response-&gt;message;
    break;

  case Auth_OpenID_SUCCESS:
    # &quot;$openid&quot; is the user openid given by Google
    $openid = $response-&gt;getDisplayIdentifier();
    $ax_resp = Auth_OpenID_AX_FetchResponse::fromSuccessResponse($response);
    # Here you could save the user data in session for further references...
    ...

    # Redirect the user to her dashboard
    header('Location: /account');
    exit();

}
</pre>
]]></content:encoded>
			<wfw:commentRss>http://claudio.cicali.name/post/2010/11/using-%c2%abfederated-login-for-google-account-users%c2%bb-in-your-application/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Google acquisisce Metaweb e Freebase. Dunque?</title>
		<link>http://claudio.cicali.name/post/2010/07/google-acquisisce-metaweb-e-freebase-dunque/</link>
		<comments>http://claudio.cicali.name/post/2010/07/google-acquisisce-metaweb-e-freebase-dunque/#comments</comments>
		<pubDate>Sun, 18 Jul 2010 10:45:12 +0000</pubDate>
		<dc:creator>claudio</dc:creator>
				<category><![CDATA[Articoli]]></category>
		<category><![CDATA[Blog]]></category>
		<category><![CDATA[freebase]]></category>
		<category><![CDATA[google]]></category>
		<category><![CDATA[metaweb]]></category>
		<category><![CDATA[semantic web]]></category>

		<guid isPermaLink="false">http://claudio.cicali.name/?p=808</guid>
		<description><![CDATA[La domanda è retorica, ovviamente, anche perché una risposta precisa non ce l&#8217;ho (nessuno ce  l&#8217;ha). Si è fatto tanto parlare in questi giorni di questa faccenda, ovvero del fatto che Google si sia comprata una delle maggiori e più innovative aziende che fanno business con il famoso, mai troppo compreso web semantico. Recentemente, per [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://claudio.cicali.name/wp-content/uploads/2010/07/freebaselogo.png"><img class="alignleft size-full wp-image-811" title="freebaselogo" src="http://claudio.cicali.name/wp-content/uploads/2010/07/freebaselogo.png" alt="" width="99" height="102" /></a>La domanda è retorica, ovviamente, anche perché una risposta precisa non ce l&#8217;ho (nessuno ce  l&#8217;ha).</p>
<p>Si è fatto tanto parlare in questi giorni di questa faccenda, ovvero del fatto che <a href="http://googleblog.blogspot.com/2010/07/deeper-understanding-with-metaweb.html">Google si sia comprata</a> una delle maggiori e più innovative aziende che fanno business con il famoso, mai troppo compreso <em>web semantico</em>.</p>
<p>Recentemente, per conto di un progettino di cui mi sto occupando, ho cercato di capire un po&#8217; meglio chi siano e cosa fanno questi di <a href="http://www.metaweb.com/">Metaweb</a>. Sono rimasto abbastanza impressionato, ma avrei desiderato un qualcosa di più. In questo articolo cercherò di mettere in chiaro quello che ho capito e quali potrebbero essere i risvolti per Google e anche in che modo Freebase e Metaweb possono già essere utili a tutti noi (e lo sono già da un po&#8217;, a dire il vero).</p>
<p>Prima di tutto, chi sono e cosa fanno? <a href="http://freebase.com">Freebase</a> e Metaweb sono due entità distinte, accomunate dalle persone che le gestiscono: la prima, che si definisce un <em>social database</em>, offre un enorme repository organizzato e maniacalmente categorizzato di entità (immaginate una entità come fosse &#8220;Harry potter&#8221; o &#8220;Steve Mc Queen&#8221; o l&#8217;&#8221;iPhone4&#8243; o &#8220;La regina d&#8217;inghilterra&#8221;). Al momento sono catalogate <strong>12 milioni</strong> di queste entità. Il secondo &#8211; Metaweb &#8211; cerca di fare business utilizzando come base dati il repository di Freebase implementando, per esempio, <strong>algoritmi di correlazione</strong> tra queste entità.</p>
<p>Dove sta la &#8220;ricchezza&#8221; di Freebase? Freebase non è un database qualunque, non è un semplice elenco di robe suddiviso per categorie. Ha diverse caratteristiche molto interessanti e peculiari (oltre alla sue notevoli dimensioni).</p>
<ul>
<li>ogni entità è definita primariamente dal suo <a href="http://wiki.freebase.com/wiki/Types">tipo</a> (raggruppati poi in domini), come ad esempio &#8220;Persona&#8221;, &#8220;Persona morta&#8221;, &#8220;Imbarcazione&#8221;, &#8220;Libro&#8221; &#8211; si noti che esiste anche il concetto di eredità tra tipologie, in quanto una &#8220;Persona morta&#8221; è comunque una &#8220;Persona&#8221; &#8211; , e da un set di proprietà o attributi che la definiscono, come &#8220;lunghezza&#8221;, &#8220;numero di posti&#8221;, &#8220;colore&#8221;, eccetera. L&#8217;insieme di questi attributi costituisce <a href="http://wiki.freebase.com/wiki/Schema">lo schema</a> di ogni tipo e, come si può, intuire, esistono decine di diversi schemi contenenti le singole precise caratteristiche di ogni entità. In altri termini, lo <em>schema</em> altro non è che <strong>l&#8217;ontologia</strong> del <em>type</em> dell&#8217;entità.</li>
<li>questa categorizzazione e alimentazione dei dati è fatto sia dal team di Freebase che dalla sua comunità. Un po&#8217; come Wikipedia, chiunque può aggiungere schemi, tipi o alimentare la base dati di schemi di entità già presenti.</li>
<li>tutti i dati dentro Freebase sono utilizzabili secondo le licenze <strong>Creative Commons</strong> (<a href="http://creativecommons.org/weblog/entry/7269">versione 3.0</a>).</li>
</ul>
<p>Dunque c&#8217;è uno sforzo enorme dietro Freebase: uno <strong>sforzo concettuale</strong> (la creazione degli schemi), uno <strong>sforzo manuale</strong> (il recupero, l&#8217;alimentazione e l&#8217;aggiornamento delle basi dati) e un <strong>sforzo iniziale</strong> derivato dalla costruzione e dalla messa in opera di un meccanismo siffatto che fosse al contempo rigoroso e scalabile. La difficoltà di creare e mantenere un sistema del genere si intuisce anche leggendo le pagine relative al capitolo <em>Challenges</em> del <a href="http://wiki.freebase.com/wiki/Main_Page">wiki di freebase</a> (vi si accede dalla home page).</p>
<p>L&#8217;accesso a questa enorme base dati è permesso attraverso tecniche all&#8217;avanguardia: non solo un set di API che ritornano JSON e JSONP, ma anche un vero e proprio linguaggio per l&#8217;interrogazione degli stessi, il <a href="http://wiki.freebase.com/wiki/MQL">MQL</a>. E come se non bastasse si sono inventati pure <a href="http://wiki.freebase.com/wiki/Acre">ACRE</a>, un sistema per scrivere direttamente (dal sito stesso, ebbene sì), e ospitare piccole applicazioni verticali che possono sfruttare direttamente l&#8217;intera base dati.</p>
<p>Una delle attività più importanti fatta da Freebase all&#8217;interno della  sua base dati è relativa a:</p>
<ul>
<li>accorgersi che due entità con lo stesso nome siano in effetti due  entità distinte (<em>Henry Ford</em> l&#8217;industriale e <em>Henry Ford</em> il giocatore di  baseball)</li>
<li>accorgersi che &#8220;presidente del consiglio italiano&#8221; e &#8220;silvio  berlusconi&#8221; siano OGGI la stessa entità (per questo si fa uso di un tipo di proprietà che si chiama <a href="http://wiki.freebase.com/wiki/CVT">CVT</a>), oppure risolvere tutti i  problemi relativi agli acronimi e nomi simili; nel video introduttivo, sul sito di Metaweb, è il caso del termine <em>Boston</em>.</li>
</ul>
<p>Tutto molto bello e potente, condito da un sito web moderno ed efficiente (sebbene non intuitivissimo da usare, se non sai esattamente quello che cerchi. Forse un poco ancora troppo &#8220;accademico&#8221;).</p>
<p>È dunque questo il famoso web semantico? No, affatto. Freebase è <em>solo</em> un maestoso strumento che mi può aiutare a fare applicazioni e siti che &#8211; loro sì &#8211; potranno creare il web semantico. Il fatto che all&#8217;interno dell&#8217;entità relativa a Tom Hanks sia presente la sua pagina di Wikipedia e il suo account Twitter non serve a niente, se non ho qualcosa che mi esponga in superficie questa informazione e, soprattutto, la metta in correlazione con altre informazioni (magari di tipo diverso). Fare browsing all&#8217;interno della base dati di Freebase è un po&#8217; come fare browsing nel CD di Encarta (passatemi il paragone ai limiti dell&#8217;offensivo).</p>
<p>Ci vuole dunque qualcuno che prenda questa informazioni e ci faccia qualcosa di utile.</p>
<p>Questo è il mestiere di Metaweb. Di massima offre i seguenti servizi:</p>
<ul>
<li><strong>consulenze</strong> per integrare le ricerche in Freebase all&#8217;interno del dominio di informazioni del cliente (es: in una testata giornalistica) o per collegare i &#8220;topic&#8221; del cliente ai &#8220;topic&#8221; di Freebase (se il cliente gestisce i film, avrà sicuramente già una propria catalogazione degli stessi, che deve essere <em>mappata</em> sulla catalogazione di Freebase)</li>
<li>offrire un <strong>sistema di correlazione</strong> tra le entità (non ho trovato traccia neanche di esempi, sul sito. Immagino si tratti di tecnologia proprietaria)</li>
<li>offre due s<strong>trumenti utilizzabili da tutti</strong>, gratuitamente: un sistema sofisticato di <a href="http://www.metaweb.com/topicsuggest">autocomplete ajax</a> sulla base dati Freebase (utile anche per offrire un sistema di tagging molto intelligente), e un <a href="http://www.metaweb.com/wordpress">plugin per WordPress</a> (e altre piattaforme di blogging) per inserire dei &#8220;flayout&#8221; contenenti informazioni addizionali e integrative relativamente a ciò che vogliamo (es: dell&#8217;azienda o del personaggio di cui stiamo parlando). I dati vengono prelevati un po&#8217; dappertutto, non solo da Freebase, e sono presenti anche dati molto recenti come le news headlines. Potete provare questo sistema dalla <a href="http://www.metaweb.com/topicblocks">pagina dei <strong>topicblock</strong></a>.</li>
</ul>
<p>Cosa se ne può fare Google, dunque, di questo sistema?</p>
<p>Prima di tutto potrebbe riprendere un po&#8217; di terreno rispetto a Bing, visto che se non ho capito male la Microsoft un paio di anni fa aveva acquistato un&#8217;<a href="http://www.zdnet.com/blog/btl/microsofts-bing-powersets-role-market-share-brand-and-other-burning-questions/18822">azienda con skill simili</a> (<strong>Powerset</strong>) e ne sta già usando la tecnologia per fornire risposte più sensate alle query sul suo motore di ricerca.</p>
<p>Poi sappiamo tutti, ormai è lampante, che con la quantità e la tipologia di fonti di informazioni che ci sono oggi, la semplice ricerca testuale non basta più. Occorre investire in strumenti semantici, davvero, che capiscano il contesto e che magari si adattino al <em>mio</em> personale pattern di ricerca. Chissà.</p>
<p>L&#8217;importante, ma questo è stato apertamente dichiarato, è che Freebase rimanga free.</p>
<p>Se siete interessati all&#8217;argomento, vi consiglio caldamente la visione del simpaticissimo video in home page del sito <a href="http://www.metaweb.com">Metaweb</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://claudio.cicali.name/post/2010/07/google-acquisisce-metaweb-e-freebase-dunque/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>Ogni tanto inciampo</title>
		<link>http://claudio.cicali.name/post/2007/11/ogni-tanto-inciampo/</link>
		<comments>http://claudio.cicali.name/post/2007/11/ogni-tanto-inciampo/#comments</comments>
		<pubDate>Mon, 12 Nov 2007 00:59:22 +0000</pubDate>
		<dc:creator>claudio</dc:creator>
				<category><![CDATA[Rant]]></category>
		<category><![CDATA[gmaps]]></category>
		<category><![CDATA[google]]></category>

		<guid isPermaLink="false">http://claudio.cicali.name/?p=39</guid>
		<description><![CDATA[Stavolta è capitato nelle Google Maps API. Prendi i tutorial, prendi la reference e ti diverti come un matto a giocarci… è tutto un “wow, figo, facile!”… poi dopo meno di due ore che ci smanetti trovi il NODO contro il proverbiale PETTINE. Quando sposti un marker trascinandolo (dragging…), appena lo lasci quello… boing, boing, [...]]]></description>
			<content:encoded><![CDATA[<p>Stavolta è capitato nelle Google Maps API. Prendi i tutorial, prendi la reference e ti diverti come un matto a giocarci… è tutto un “wow, figo, facile!”… poi dopo meno di due ore che ci smanetti trovi il NODO contro il proverbiale PETTINE.</p>
<p>Quando sposti un marker trascinandolo (dragging…), appena lo lasci quello… boing, boing, boing… rimbalza con un effetto molto figo.</p>
<p>Ho pensato “<em>Uh, ganzo, adesso lo faccio palleggiare appena lo CREO, ‘sto marker</em>“… Eh NO!… non si può… anzi, si può perché loro (biG) lo sanno fare. Ma non è documentato… e se non è documentato <strong>TI ATTACCHI</strong> perché il codice non lo puoi leggere :)</p>
<p>Non c’è scampo: il software proprietario è SEMPRE, per un motivo o per l’altro, UNA MERDA (quando lo è il FOSS, puoi perlmeno modificartelo).</p>
<p>Amore &amp; Odio</p>
]]></content:encoded>
			<wfw:commentRss>http://claudio.cicali.name/post/2007/11/ogni-tanto-inciampo/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

