G
G
GreatX2019-08-12 07:40:27
PHP
GreatX, 2019-08-12 07:40:27

Code from Php to Node.js?

Please help with api. Can't translate to Node.js

$param['secret'] 	= ""; 	//ключ api
$param['order_id']	= ""; 	//id заказа, полученный из метода new_order

//подготовка запроса	
foreach ($param as $key => $value) { 
$data .= "&".$key."=".$value;
}

$ch = curl_init(); 
curl_setopt($ch, CURLOPT_URL, "https://app.frontpad.ru/api/index.php?get_status"); 
curl_setopt($ch, CURLOPT_FAILONERROR, 1); 
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1); 
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($ch, CURLOPT_TIMEOUT, 30); 
curl_setopt($ch, CURLOPT_POST, 1); 
curl_setopt($ch, CURLOPT_HEADER, true); 
curl_setopt($ch, CURLOPT_POSTFIELDS, $data); 
$result = curl_exec($ch); 
curl_close($ch); 

//результат
echo $result;

it is not clear where secret to send
secret is an api key
request.post('https://app.frontpad.ru/api/index.php?get_products', function (err, res, body) {
        if (err) {
            console.log('error:', err);
        }
        console.log('statusCode:', res && res.statusCode); 
        console.log('body:', res.body); 
    });

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Michael, 2019-08-12
@GreatX

request.post('https://app.frontpad.ru/api/index.php?get_products', {form:{secret: 'key'}})

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question