A
A
Artur Nurullin2014-11-06 16:33:24
PHP
Artur Nurullin, 2014-11-06 16:33:24

How to translate php code to asp.net?

Good day to all! Could you help me with the translation of the functionality of the php class to asp.net asp.net I know, but I can’t figure it out in php - I’ll give part of the code in php -

//=================================================
  function getData($proc,$parm=false) {
    if(!$parm) $parm = array();
    $command = array('proc_id'=>$proc,'parm'=>$parm);
    $auth = array('client_name'=>$this->client_name,'client_pwd'=>$this->client_pwd);
    $data = array('command'=>$command,'auth'=>$auth);
    $data = $this->sendPost($this->server,$data);
    return $data;
  }
//=================================================
  function sendPost($url,$data) {
    $data = array('postdata'=>serialize($data));
    $data = array_map($this->code_method.'encode',$data);
               // Что он в дату сохраняет ? какие параметры получаются с точки зрения http после того // как мы сохраняем массив в массиве массива ?
    $data = http_build_query($data);
    $post = $this->genPost($url,$data);
    $url = parse_url($url);
    $fp = @fsockopen($url['host'], 80, $errno, $errstr, 30); 
    if (!$fp) return false;
    $responce = '';
    fwrite($fp,$post); 
    while ( !feof($fp) )
      $responce .= fgets($fp);
    fclose($fp);
//var_dump('<pre>',$responce);	// (отладка - показать ошибки php в вызываемом модуле)
    $responce = $this->NormalizePostResponce($responce);
    return $responce;
  }

Full source code here - Autoeuro Client

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dmitry Entelis, 2014-11-06
@Splo1ter

As I understand it, you do not understand the piece

$data = array_map($this->code_method.'encode',$data);

It takes the value of the code_method parameter from the current object (you can see from your link that it is "base64_"), adds the string "encode" to it (it turns out base64_encode) and applies this function to each element of the $data array, saving the resulting array back to $data

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question