Answer the question
In order to leave comments, you need to log in
How to send an application from a site on Bitrix to Google sheets?
Task: When sending an application from the site, you need to
add the corresponding lines
in the "DB for applications" file
https://docs.google.com/spreadsheets/d/1_FCtpyjQaD... :
Sheet "Leads": (one line)
Lead ID: (+1 to id to the last line)
Lead source ID: 1
Lead_name: (from request)
Phone: (from request)
Instagram link: ""
Lead gender: 0
Registration date: new Date().getTime()/(1000* 3600*24)+25569 // this is the formula for converting to the database date format
At the moment, I made a get request https://script.google.com/macros/s/AKfycbwmsKXbNeH...
it adds name to the name field, and nomer to phone field to the sheet I need
Now I don’t know how to send this request from the site, so that it doesn’t require authorization in Google
Site on Bitrix
Answer the question
In order to leave comments, you need to log in
Completed in the end through a post
in Google like this
var BD = SpreadsheetApp.openById('1_FCtpyjQaD2rBn_qnqtDm25TjM4VscYssySqxvhUj8s')//БД
var lid_sheet = BD.getSheetByName("Лиды")//лист Лиды
var lid_rang = lid_sheet.getRange(2,1,lid_sheet.getLastRow()-1+1,lid_sheet.getLastColumn())//Ранги Лиды
var lid_val = lid_rang.getValues();
var id_lid = lid_val[lid_val.length-1-1][0]+1
var row = lid_val.length
lid_rang.getCell(row,1).setValue(id_lid)// ИД лида
lid_rang.getCell(row,2).setValue(1)// ИД источника
lid_rang.getCell(row,3).setValue(e.parameter.p1)// Имя_лида
lid_rang.getCell(row,4).setValue(e.parameter.p2)// Телефон
lid_rang.getCell(row,6).setValue(0)// Пол лида
lid_rang.getCell(row,7).setValue(new Date().getTime()/(1000*3600*24)+25569)// Дата регистрации
return ContentService.createTextOutput(JSON.stringify(e.parameter.p2))
$myCurl2 = curl_init();
curl_setopt_array($myCurl2, array(
CURLOPT_URL => 'https://script.google.com/macros/s/AKfycbwmsKXbNeHUPjqn_ujt92SM2xtL7Of7jZg9DpDyEvt0qTCveHk/exec',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_POST => true,
CURLOPT_POSTFIELDS => http_build_query(array(
'p1' => $arEventFields['NAME'],
'p2' => $arEventFields['PHONE'],
))
));
$response = curl_exec($myCurl2);
curl_close($myCurl2);
Publish your script on your behalf to everyone on the Internet.
Remember that if you make changes to the script, you will have to publish it again.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question