Accediendo a Google Analytics con Curl

Enviado por alegg | En APIS, PHP | El 08-09-2009

0

Para un proyecto reciente me han pedido mostrar en una pagina algunos datos generados por Google Analytics. Para hacerlo, podemos utilizar la Data Export API.

Conectar a nuestra cuenta de Analytics, es muy fácil utilizando la libreria de PHP, curl.


header("Content-type: text/plain");

$email = "tumailde@googleanalytics.com";
$password = "xxxxxxx";

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://www.google.com/accounts/ClientLogin");
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch,CURLOPT_HEADER,true);
curl_setopt($ch, CURLOPT_POSTFIELDS,"accountType=GOOGLE&Email=$email&Passwd=$password&service=analytics&source=untest");
curl_exec($ch);
curl_close($ch);

Aqui les dejo muchas aplicaciones que han sido creadas con esta API.

Write a comment