Come ben sapete, Google ha da poco lanciato il social network Google Plus. Come tutti i social network c’è la possibilità di aggiungere gli amici “cerchia”, di Pubblicare contenuti sulla propria bacheca e chi più ne ha più ne metta.
In questo tutorial vedremo come utilizzare le API di Google Plus utilizzando PHP.

 
< ?php
require_once ‘/gplusapi/src/apiClient.php’;
require_once ‘/gplusapi/src/contrib/apiPlusService.php’;
 
session_start();
 
$client = new apiClient();
$client->setApplicationName("Google+ PHP Starter Application");
// Visit https://code.google.com/apis/console?api=plus to generate your
// client id, client secret, and to register your redirect uri.
$client->setClientId(‘enter_here’);
$client->setClientSecret(‘enter_here’);
$client->setRedirectUri(‘http://sito.com);
$client->setDeveloperKey(‘
enter_here‘);
$plus = new apiPlusService($client);
 
if (isset($_GET['
code'])) {
  $client->authenticate();
  $_SESSION['
token'] = $client->getAccessToken();
  header(‘
Location: http://’ . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF']);
}
 
if (isset($_SESSION[‘token’])) {
  $client->setAccessToken($_SESSION[‘token’]);
}
 
if ($client->getAccessToken()) {
  $me = $plus->people->get(‘me’);
 
  echo "
Your Profile:
 
"
;
  echo "Your ID: " . "" . $me[‘id’] . "" . "";
  echo "Display Name: " . $me[‘displayName’] . "";
  echo "Tagline: " . $me[‘tagline’] . "";
  echo "Gender: " . $me[‘gender’] . "";
  echo "About me: " . $me[‘aboutMe’] . "";
  echo "Relationship Status: " . $me[‘relationshipStatus’] . "";
  echo "Profile Picture: ";
 
  // The access token may have been updated lazily.
  $_SESSION[‘token’] = $client->getAccessToken();
} else {
  $authUrl = $client->createAuthUrl();
  print "";
}
?>
 

fonte: www.sastgroup.com ? Vai al post originale