Google apps script for Spreadsheet - russian symbol substitute as a question mark

41 views Asked by At

If you open a link in brazuere __ - that everything is OK, an entry is added in Russian. If the same link run from php script - it added a question mark. Here's the code dlyastranitsy pgoogl appps

 function doGet(e) {
  var ss = SpreadsheetApp.openById("14EWkOKE4QONFQ7UAi5Kf1vYnTgSXzCH_ZJZ5fzo3dIU");
  var ss = ss.getSheetByName('Лист');
  var rr=getFirstEmptyRowWholeRow(ss);
  ss.insertRowAfter(rr);
  Logger.log(e.parameter.tovar);
  ss.getRange('A'+rr).setValue(e.parameter.tovar);   
}
function getFirstEmptyRowWholeRow(ss) {
  var values = ss.getDataRange().getValues();
  var row = 0;
  for (var row=0; row<values.length; row++) {
    if (!values[row].join("")) break;
  }
  return (row+1);
}

Here is the code php file

function obrab_url($s){
    return str_replace(' ','%20',nl2br($s));
}


$tovar='Коврики в сало н для тойоты колродлла аповдыало xcz lkjxzc ждмлчсяо8 987908';
$phone='09873569734';
$address='киев у богакая 8 выалвыоад лдож'; 
$cena='352 555';
$postavshik='[колч код 535] плюс [родлордло]';
$s='https://script.google.com/macros/s/AKfycbxGvknF1mMX6YCq8KZLltuWqJZ0QfthgGHnwOR11xaSPXQ91Ozb/exec?tovar='.obrab_url($tovar).'&phone='.obrab_url($phone).'&adres='.obrab_url($address).'&price='.obrab_url($cena).'&code='.obrab_url($postavshik);
echo $s.'<br>'; 

  $ch = curl_init(); 
  // GET запрос указывается в строке URL 
  curl_setopt($ch, CURLOPT_URL, $s); 
  curl_setopt($ch, CURLOPT_HEADER, false); 
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); 
  curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 30); 
  curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows; U; Windows NT 5.1; ru; rv:1.9.0.1) Gecko/2008070208'); 
  $data = curl_exec($ch); 
  curl_close($ch); 
  echo $zap;
0

There are 0 answers