En esto soy muy nuevo,apenas empece hoy con una lectura, y encontre en internet un tutorial muy bueno , donde te dan un codigo a probar.
Código PHP:
<?php
/*
* Include the Google clientAPI and the Service for Google Plus
*/
require_once 'google-api-php-client/src/apiClient.php';
require_once 'google-api-php-client/src/contrib/apiPlusService.php';
/*
* Start a PHP Based Session, used to help track the state of the transaction
*/
session_start();
/*
* Instantiate the client and the service object.
* Notice you pass client into the service object
*/
$client = new apiClient();
$plus = new apiPlusService($client);
/*
* Set your credentials from Part 1
*/$client->setClientId('miid.apps.googleusercontent.com');
$client->setClientSecret('miclientsecret);
$client->setRedirectUri('https://www.misitio.com.mx/oauth2callback');
$client->setDeveloperKey('mikeydeveloper');
/*
* We need to tell Google's Auth servers what we want to access
* Scopes are pointers to data, you have different scopes for areas of Google
* If you wanted to access Google+ and Gmail data for this client, you would request both scopes
*/
$client->setScopes(array(
'https://www.googleapis.com/auth/plus.me'
));
/*
* First we check to see if the user has requested us to clear there login information
* We do this by checking our local url for the logout param, and if exists, we clear the access
* token from our session
*/
if(isset($_REQUEST['logout'])) //GET or POST or COOKIE
{
unset($_SESSION['access_token']);
}
/*
* When the user authenticates your request, Google redirects the client back to this page
* passing in params in the URL, if the code param is there, it means that they clicked allow
* and Google is sending back the code telling us to authenticate it.
* if this is true, we redirect the user to this page, but without the code, storing it in the session
*/
if(isset($_GET['code']))
{
$client->authenticate();
$_SESSION['access_token'] = $client->getAccessToken();
header('Location: http://' . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF']);
}
/*
* if all has gone well, the access token should be in the session
* so we can now tell the client what the valid access token is
*/
if(isset($_SESSION['access_token']))
{
$client->setAccessToken($_SESSION['access_token']);
}
/*
* the getAccessToken() method will return the token if were authorized to make requests for data
* This would normally indicate that the user granted us access and there still logged in
*/
if ($client->getAccessToken())
{
/*
* Now were logged in, we can perform requests for data, so let's get started with a simple /me
* Request (https://www.googleapis.com/plus/v1/people/me) which will return a Person Object
* Person Object {https://developers.google.com/+/api/latest/people#resource}
*/
$me = $plus->people->get('me');
/*
* We can also perform other requests such as Activities
* https://developers.google.com/+/api/latest/activities/list
*/
$activities = $plus->activities->listActivities('me', 'public', array(
'maxResults' => 25
));
/*
* The activities array holds an inner array called [items], this is each actual Activity
* https://developers.google.com/+/api/latest/activities#resource
*/
foreach($activities['items'] as $activity)
{
$activity['object']['content']; //This is the content of the post
}
}
else
{
/*
* Seems the user is not logged in, we need to display a link for the user to authenticate
* Getting the redirect link to google is very simple, you just need to display it for them.
*/
$redirectLink = $client->createAuthUrl();
/*
* And we simply create a link for the user to click.
*/
echo sprintf('<a href="%s">%s</a>', $redirectLink, 'Login to Google+');
}
?>
Código:
Este es el enlace de prueba : http://www.panuquenses.com.mx/plus/datos.phpError de conexión SSL No se puede establecer una conexión segura con el servidor. Esto se puede deber a un problema con el servidor o quizá sea necesario un certificado de autenticación de cliente que no tienes. Error 107 (net::ERR_SSL_PROTOCOL_ERROR): Error de protocolo SSL.
Cuando lo intento en internet explorer ni siquiera funciona .
¿Que puede ser?.