php sequence works perfectly on Wamp but not on external server

1

I have on my local server with wamp a php file where I have a code to get the data of a form and send them to the google sheet with a google sheet library. But when I take these files the library and the php code to the external server of my web, when I make a test the php page goes blank and does not work since I do not enter the records to the Google sheet.

I leave the code:

<?php
// Composer's auto-loading functionality
require "vendor/autoload.php";

use Google\Spreadsheet\DefaultServiceRequest;
use Google\Spreadsheet\ServiceRequestFactory;

$nombreAplicacion = "PhpSheet";
$direccionCorreo = "[email protected]";
$idCliente = "3a5bbd2c9ada9a0f85e8fc1516157400c754d6fa";

// Nombre del SpreadSheet creada
$nombreSpreahSheet = "Php Sheet volcado";
// Nombre de hoja de cálculo
$hojaCalculo = "Hoja 2";

$scope = array('https://spreadsheets.google.com/feeds');

// Inicializamos Google Client
$client = new Google_Client();
$client->setApplicationName($nombreAplicacion);
$client->setClientId($idCliente);

// credenciales, scope y archivo p12. Agregar el correcto Path al archivo p12
$cred = new Google_Auth_AssertionCredentials(
$direccionCorreo,
$scope,
file_get_contents('PhpSheet-3a5bbd2c9ada.p12')
);

$client->setAssertionCredentials($cred);

// si expiro el access token generamos otro
if($client->isAccessTokenExpired()) {
$client->getAuth()->refreshTokenWithAssertion($cred);
}

// Obtenemos el access token
$obj_token = json_decode($client->getAccessToken());
$accessToken = $obj_token->access_token;

// Inicializamos google-spreadsheet-client
$serviceRequest = new DefaultServiceRequest($accessToken);
ServiceRequestFactory::setInstance($serviceRequest);

//Obtenemos los Spreadsheets disponibles para las credenciales actuales
$spreadsheetService = new Google\Spreadsheet\SpreadsheetService();
$spreadsheetFeed = $spreadsheetService->getSpreadsheets();

// Obtenemos la spreadsheet por su nombre
$spreadsheet = $spreadsheetFeed->getByTitle($nombreSpreahSheet);

// Obtenemos las hojas de cálculo de la spreadsheet obetenida
$worksheetFeed = $spreadsheet->getWorksheets();

// Obtenemos la hoja de cálculo por su nombre
$worksheet = $worksheetFeed->getByTitle($hojaCalculo);
$listFeed = $worksheet->getListFeed();


 $dataAgregar = array('nombre' => $_SESSION['nombre'],
 'email' => $_SESSION['email'],
 'telefono' => $_SESSION['phone'],
 'mensaje' => $_SESSION['mensaje'],
 'landing' =>  $landingP
 );
// Agregar datos
$listFeed->insert($dataAgregar);
echo ('Se han insertado correctamente los registros')
?>
    
asked by AitorUdabe 01.09.2016 в 11:41
source

1 answer

1

After research I found the problem and the solution.

The problem is that in the server where I have the web has a version of PHP 5.3 and in wamp server is 5.6, I checked in another web in external server with php 5.6 and the php script works perfectly. Yes, the error is the php version of the server and the solution is to change / update the PHP version from 5.3 to 5.6

    
answered by 01.09.2016 / 13:45
source