I
I
Ivan2018-05-18 09:33:25
PHP
Ivan, 2018-05-18 09:33:25

When a parameter of Russian characters is passed in a GET request, the script does not work. What is the reason?

From 1C there is a GET request. One of the parameters is the file name. And it is sometimes called Russian symbols.

https://мойсервер/telegrambot/file.php?apibot=24953021_______Pnjwywdkg&chatid=-1003333102111&document=Продажи_месяц_май.xls

For example, in this form. And then the file is not sent. If the name contains just numbers: 2018.xls, then everything works fine and is sent. Tried different things. What is the problem?
Below code:
header('Content-Type: text/html; charset= utf-8');
  $botToken = $_GET['apibot'];
  $website="https://api.telegram.org/bot".$botToken;
  $chatId = $_GET['chatid']; //Receiver Chat Id
  $caption = $_GET['caption'];
  $file_send = "./file_temp/".$_GET['document']; 
  $file_s = iconv("windows-1251","UTF-8",$file_send);
  $file_name_with_full_path = realpath($file_s);

  
    $params=array(
    'chat_id'=>$chatId,
    'document'     => '@'.$file_name_with_full_path,
    'caption'   => $caption,
    );
  $proxy_port = "1080";
  $proxy_ip = "___.me";
  $loginpassw = '126____1ba';
  $ch = curl_init($website . '/senddocument');
  curl_setopt($ch, CURLOPT_HEADER, false);
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  curl_setopt($ch, CURLOPT_POST, 1);
  
  curl_setopt($ch, CURLOPT_PROXYPORT, $proxy_port);
    curl_setopt($ch, CURLOPT_PROXYTYPE, CURLPROXY_SOCKS5);
    curl_setopt($ch, CURLOPT_PROXY, $proxy_ip);
    curl_setopt($ch, CURLOPT_PROXYUSERPWD, $loginpassw);
  
  curl_setopt($ch, CURLOPT_POSTFIELDS, ($params));
  curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);	
  $result = curl_exec($ch);
  curl_close($ch);

Answer the question

In order to leave comments, you need to log in

2 answer(s)
R
Roman Terekhin, 2018-05-18
@RomaZveR

1) I think this line is redundant
2) The line above is better to wrap

$file_send = './file_temp/'.basename($_GET['document']);

D
DieZz, 2018-05-18
@DieZz

The problem is that this url is invalid (
RFC 1738 ), i.e. contains Russian characters. In your case the link should look something like this
A cursory Google search says that 1C has a function EncodeString()

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question