<?php header('Content-type: text/html; charset=utf-8' ); ?>
<?php
// для метода POST
$product[] = $_POST['data1'][$num+1];
$product_kol[] = $_POST['data2'];
//детали заказа в кодировке utf-8
$param['secret'] = "NhKf8yQKhEtB4iSBaYyBtTiRHk6ZsF66QEaN3Rk8fGA9SdAT2YfeDsZaFR2ZiSR2hSB9yQ8EhyD3A4HkNRtb8ddDY4n6G5TSHfR6YNz573TySrGs73y65AzQrKGZDnDayf7eTs9RfS938Ge6yD2n4i4eYA5kNtn8BhbhDa2HT2zStEKR7A6ZHZ5thYFYbYSE5YNtYB5EkrhGTYiQfeBS4s99aFTdnBGfhhB6Ksz2GGtrrF6AKteBKdBNKf"; //ключ api
$param['street'] = $_POST['data5']; //улица
$param['phone'] = $_POST['data4']; //телефон
$param['descr'] = $_POST['data6']; //комментарий
$param['name'] = $_POST['data3']; //имя клиента
$param['datetime'] = $_POST['data7']; //datetime
//подготовка запроса
foreach ($param as $key => $value) {
$data .= "&".$key."=".$value;
}
//содержимое заказа
foreach ($product as $key => $value){
$data .= "&product[".$key."]=".$value."";
$data .= "&product_kol[".$key."]=".$product_kol[$key]."";
if(isset($product_mod[$key])) {
$data .= "&product_mod[".$key."]=".$product_mod[$key]."";
}
}
//отправка
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://app.frontpad.ru/api/index.php?new_order");
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_POSTFIELDS, $data);
$result = curl_exec($ch);
curl_close($ch);
//результат
echo $result;
?>
<?php header('Content-type: text/html; charset=utf-8' ); ?>
<?php
// для метода POST
$product[] = $_POST['data1'][$num+1];
$product_kol[] = $_POST['data2'];
//детали заказа в кодировке utf-8
$param['secret'] = "NhKf8yQKhEtB4iSBaYyBtTiRHk6ZsF66QEaN3Rk8fGA9SdAT2YfeDsZaFR2ZiSR2hSB9yQ8EhyD3A4HkNRtb8ddDY4n6G5TSHfR6YNz573TySrGs73y65AzQrKGZDnDayf7eTs9RfS938Ge6yD2n4i4eYA5kNtn8BhbhDa2HT2zStEKR7A6ZHZ5thYFYbYSE5YNtYB5EkrhGTYiQfeBS4s99aFTdnBGfhhB6Ksz2GGtrrF6AKteBKdBNKf"; //ключ api
$param['street'] = $_POST['data5']; //улица
$param['phone'] = $_POST['data4']; //телефон
$param['descr'] = $_POST['data6']; //комментарий
$param['name'] = $_POST['data3']; //имя клиента
$param['datetime'] = $_POST['data7']; //datetime
//подготовка запроса
foreach ($param as $key => $value) {
$data .= "&".$key."=".$value;
}
//содержимое заказа
foreach ($product as $key => $value){
$data .= "&product[".$key."]=".$value."";
$data .= "&product_kol[".$key."]=".$product_kol[$key]."";
if(isset($product_mod[$key])) {
$data .= "&product_mod[".$key."]=".$product_mod[$key]."";
}
}
//отправка
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://app.frontpad.ru/api/index.php?new_order");
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_POSTFIELDS, $data);
$result = curl_exec($ch);
curl_close($ch);
//результат
echo $result;
?>
function sendfronpad() {
var secret = 'Zti4nrrkFnbD4ybFYdkN9YtDBtfTKHFz4Rnd6ErATt3KQ5dA7s96atzBQEhnbQK5t38ksnNaHDKktRKn7Kh75GzG9FYbhy6Dh5RDfrDRSa5aRDrNbAG666D6Bk7HG4aSYSf48KGQKARr4645sA2ksneTBbr85sQN8ZE7y9K7AninfbfBB6NThTBKYSHQ9in87T5sSDkdRAt2BBk4y3HFH8dtRN7Q2iKY5DaK5nQGN8tbAG5TzDn6Askb6h'; //секрет авторизации
var product = [];
var product_kol = [];
{/literal}
{assign var="num" value="0"}
{foreach $purchases as $purchase}
product[{$num}] = '{$purchase->variant->sku|escape}'; //массив внешних кодов товаров
product_kol[{$num}] = '{$purchase->amount}'; //массив кол-ва товаров
{assign var="num" value=$num+1}
{/foreach}
var street = '{$order->address|escape}'; //адрес
var name = '{$order->name|escape}';
var mail = '{$order->email|escape}'; //mail
var phone = '{$order->phone|escape}'; //телефон
var product_price = '{$order->total_price|convert}';
var order_id = '{$order->id}';
var invalid_product_keys = '{$purchase->variant->sku|escape}';
var descr = '{$order->comment|escape}{literal}'; //примечание
$.ajax( {
url: 'https://cors-anywhere.herokuapp.com/https://app.frontpad.ru/api/index.php?new_order',
contentType: 'application/json',
dataType: 'json',
crossDomain: true,
type: "POST",
secret:secret,
'product[]':product,
'product_kol[]':product_kol,
street:street,
phone:phone,
descr:descr,
name:name,
mail:mail,
product_price:product_price,
order_id:order_id,
invalid_product_keys:invalid_product_keys
});
}
Request URL: https://cors-anywhere.herokuapp.com/http://app.frontpad.ru/api/index.php?new_order
Request Method: POST
Status Code: 200 OK
Remote Address: 52.4.86.246:443
Referrer Policy: no-referrer-when-downgrade
Access-Control-Allow-Origin: *
Access-Control-Expose-Headers: server,date,content-type,transfer-encoding,connection,x-powered-by,vary,content-encoding,x-final-url,access-control-allow-origin
Connection: keep-alive
Content-Encoding: gzip
Content-Type: text/html; charset=windows-1251
Date: Thu, 25 Apr 2019 07:51:06 GMT
Server: nginx/1.2.1
Transfer-Encoding: chunked
Vary: Accept-Encoding
Via: 1.1 vegur
X-Final-Url: http://app.frontpad.ru/api/index.php?new_order
X-Powered-By: PHP/5.4.45-0+deb7u2
X-Request-Url: http://app.frontpad.ru/api/index.php?new_order