P
P
petriichuk2016-12-29 17:36:26
Google
petriichuk, 2016-12-29 17:36:26

Is it possible to parse data from a Google Sheet every time a php page is opened?

Hello! There is a table (shared) in Google Sheet with prices, you need to pull up these prices on the PHP page. Found this documentation but there it requests user authorization in Google. Is it possible to somehow parse even if the user does not have a Google account?
Or is the only way out is to do server-to-server communication and store the data in a database or json file?

Answer the question

In order to leave comments, you need to log in

4 answer(s)
P
petriichuk, 2016-12-29
@petriichuk

Earned, like quickly and without glitches:

<?php
$apiKey="ВашКлюч"; //apikey from GoogleDevConsole/Credentials
include_once 'vendor/autoload.php'; //library
$client = new Google_Client();
$client->setApplicationName("Client_Library_Examples");
$client->setDeveloperKey($apiKey);
$service = new Google_Service_Sheets($client);
$spreadsheetId = 'ВашИдДокумунта'; //change to your
$range = 'A1:B';
$response = $service->spreadsheets_values->get($spreadsheetId, $range);
$values = $response->getValues();
if (count($values) == 0) {
  print "No data found.\n";
} else {
  print "Name, Major:\n";
  foreach ($values as $row) {
    printf("<p>%s, %s</p>", $row[0], $row[1]);
  }
}
 
?>

Installing the library
How to get a Simple API access key

F
frees2, 2016-12-29
@frees2

Yes, only it loads a little slower than it should, you just need to open this file for everyone, but it turned out that it’s better to store it on your server, I don’t know why data is slowly loaded from Google and sometimes there are some repairs.

$(document).ready(function() { $('#btn1666').hover(function(){ $(this).remove();
$.getJSON('https://www.googledrive.com/host/0B5B...................5QkE4Nnc', function(data) {for(var i=0;i<data.users.length;i++){

$('.canal').append('<br><input type=\"image\" name=\"message\" value=\"'+data.users[i].id+ '\" src=\"'+data.users[i].num+'\"> ' + data.users[i].text + ' <br><br><br>' ).hide().fadeIn(1000); 
}

if( i>1){  $('.canal2').html('<br>'+i+ ' - Ролики. Больше... Жми!<br><hr>' );        }

}  )} );return false;});

A
Andrew, 2017-06-04
@valya0502

Could this be a starting point?
https://jsfiddle.net/np1ecv2h/1/

T
TMLEX, 2017-06-04
@TMLEX

Perhaps the dumbest option: 11 objects, and then everything is simple - set positions, rotate the text - transform, round the elements: border-radius, I won’t even say the rest.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question