Foros del Web » Programando para Internet » PHP »

Problemas con SSL con una aplicacion de Google +

Estas en el tema de Problemas con SSL con una aplicacion de Google + en el foro de PHP en Foros del Web. Hola que tal, vengo con una duda con respecto a la API de google + , usando php. En esto soy muy nuevo,apenas empece hoy ...
  #1 (permalink)  
Antiguo 24/10/2011, 11:22
Fsg
 
Fecha de Ingreso: junio-2009
Mensajes: 155
Antigüedad: 14 años, 10 meses
Puntos: 5
Problemas con SSL con una aplicacion de Google +

Hola que tal, vengo con una duda con respecto a la API de google + , usando php.
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+');
    }
    
    
?>
El problema es que al ejecutar el enlace, si me aparece para ingresar a mi cuenta de google + para autorizacion, pero una vez que autorizo, me sale un error en google chrome:

Código:
Error 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.
Este es el enlace de prueba : http://www.panuquenses.com.mx/plus/datos.php

Cuando lo intento en internet explorer ni siquiera funciona .
¿Que puede ser?.

Etiquetas: google, ssl, aplicaciones
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 17:23.