Acaban de anunciar la API de Google+, algo que mucha gente estaba pidiendo para que esta plataforma pueda despegar.
Pues ya se han currado una librería en PHP (en beta) para que podamos probar con ella:
// Include the library files
require_once 'google-api-php-client/src/apiClient.php';
require_once 'google-api-php-client/src/contrib/apiBuzzService.php';
// Create the apiClient and Buzz service class:
$apiClient = new apiClient();
$buzz = new apiBuzzService($apiClient);
// If an OAuth token was stored in the session, use that. Otherwise go through the OAuth flow.
session_start();
if (isset($_SESSION['access_token'])) {
$apiClient->setAccessToken($_SESSION['access_token']);
} else {
$apiClient->setAccessToken($apiClient->authenticate());
// In a real application this would be stored in a database, and not in the session!
$_SESSION['access_token'] = $apiClient->getAccessToken();
}
// Make an API call
$activities = $buzz->activities->listActivities('@me', '@consumption');
// And echo the returned activities
echo '<pre>Activities: ' . print_r($activities, true) . '</pre>';
// Save the updated access token in the session.
$_SESSION['access_token'] = $apiClient->getAccessToken();
Habrá que probarla
Google+ API PHP Client


sábado, septiembre 17, 2011
Arley Triana Morín

0 comentarios:
Publicar un comentario en la entrada