Using Zend_Gdata_Spreadsheets for public spreadsheets?

I have this code that works to download a Google spreadsheet and load some data from it. If the published table is publicly available, how can I change the code so as not to require a username / password?

$key="keytothespreadsheet";
$user="test@example.com";
$pass="*****";

$authService = Zend_Gdata_Spreadsheets::AUTH_SERVICE_NAME;
$httpClient = Zend_Gdata_ClientLogin::getHttpClient($user, $pass, $authService);
$gdClient = new Zend_Gdata_Spreadsheets($httpClient);
$query = new Zend_Gdata_Spreadsheets_DocumentQuery();
$query->setSpreadsheetKey($key);
$feed = $gdClient->getWorksheetFeed($query);
print_r($feed);
+3
source share
2 answers

In the following line, an HTTP client is optional:

$gdClient = new Zend_Gdata_Spreadsheets($httpClient);


So, just don't pass by. The following equivalents:

$gdClient = new Zend_Gdata_Spreadsheets();
// or
$gdClient = new Zend_Gdata_Spreadsheets(null);
// or
$gdClient = new Zend_Gdata_Spreadsheets(new Zend_Http_Client());
+2
source

@Matt, . @Derek Illchuk, . , , :

  • , > - , a > . " ", : " 200, 400. URL- . , URL-, .

  • " " " ___.". : " 200, 403 . , ".

  • Google, " 'private' " "." , "" "" . : " 200, 501 ".

:

    $spreadsheetService = new Zend_Gdata_Spreadsheets(null);
    $query = new Zend_Gdata_Spreadsheets_CellQuery();
    $query->setSpreadsheetKey($spreadsheetKey);
    $query->setWorksheetId($worksheetId);
    $query->setVisibility('public'); //options are 'private' or 'public'
    $query->setProjection('basic'); //options are 'full' or 'basic'
    $cellFeed = $spreadsheetService->getCellFeed($query);

    foreach ($cellFeed as $cellEntry) {
        $text = $cellEntry->content->text;
        //Do something
        break; //I only wanted the first cell (R1C1).
    }
0

Source: https://habr.com/ru/post/1725688/


All Articles