K
K
kirusha_gorin2016-08-09 21:44:43
API
kirusha_gorin, 2016-08-09 21:44:43

How can I implement the transfer of data from the site to google spreadsheets?

There is a site with design courses. For dynamic remarketing, you need to constantly update the data (open course or closed). To do this, you need to pass this parameter from the site to the tables. A similar example of transferring data from a site to Google Spreadsheets will be interesting.

Answer the question

In order to leave comments, you need to log in

3 answer(s)
V
Victor L, 2016-08-11
@Fzero0

1)Create a google spreadsheet,
2)Script editor tools

function doGet(e)
{
  // 1yLhgYQ3BrAC40gt4EjM9Ye4NZn03i4dNLDNuqZNxFw4 - id вашей таблицы (можно и по другому)
   var sheet = SpreadsheetApp.openById("1yLhgYQ3BrAC40gt4EjM9Ye4NZn03i4dNLDNuqZNxFw4");
   var n=sheet.getRange("A1").getValue()+2; 
   sheet.getRange("A"+n).setValue(e.parameter.p1); // первый параметр
   sheet.getRange("B"+n).setValue(e.parameter.p2);
   sheet.getRange("C"+n).setValue(e.parameter.p3);
   sheet.getRange("D"+n).setValue(e.parameter.p4);
   sheet.getRange("E"+n).setValue(e.parameter.p5);
   sheet.getRange("F"+n).setValue(e.parameter.p6); // последний
   sheet.getRange("A1").setValue(n-1);
}

3) Deploy the script as an application
4) send data to the script
$ch = curl_init();
        $url = 'https://script.google.com/macros/s/..QXmd4uzygY/exec?';
        $url .= http_build_query(['p1' => $category, 'p2' => $section, 'p3' => $images, 'p4' => $name, 'p5' => $inf1, 'p6' => $inf2]);
        curl_setopt($ch, CURLOPT_URL, $url);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER,true);
        if (curl_exec($ch)) {
            echo 'good<br/>';
            curl_close($ch);  // закрываем сеанс    
        }
        return true;

G
Golover, 2016-10-18
@Golover

Functions importxml, importhtml

R
Roman, 2016-08-10
@r_zaycev

First link in google: php api save data to google spreadsheet

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question