Commit dfffb611 authored by Kulya's avatar Kulya 😊

Billz curl req add progress func

parent d14a4961
......@@ -2722,7 +2722,7 @@ CFU=';
'agentProcessBxLeads' => 65,
'checkListenerStatus' => 30,
'agentsCheckDeletedUsersNumber' => 60,
'billz_catalog_infos_synch' => 120,
// 'billz_catalog_infos_synch' => 12000,
'process_orders_synch' => 60,
];
......
......@@ -565,9 +565,10 @@ class AloVoiceRest
];
echo "Загрузка данных из Billz...";
$sdata = self::get_products_last_update(); //"2017-01-01T00:00:00Z";
echo "Загрузка изменения из Billz на дату: ".$sdata.":...";
$first = BillzRest::getProducts($sdata);
......
......@@ -184,10 +184,8 @@ require_once (__DIR__.'/keys.php');
$result["params"] = $sendData;
$result["url"] = $url;
static::setLog( $url, '--==== Before billzCurl URL:' );
try
{
static::setLog( $url, '--==== InTry billzCurl URL:' );
$obCurl = curl_init();
curl_setopt_array($obCurl, array(
......@@ -203,6 +201,8 @@ require_once (__DIR__.'/keys.php');
CURLOPT_POSTFIELDS =>$sendData,
CURLOPT_SSL_VERIFYPEER =>false,
CURLOPT_SSL_VERIFYHOST =>false,
CURLOPT_NOPROGRESS => false ,
CURLOPT_PROGRESSFUNCTION => 'progress',
CURLOPT_HTTPHEADER => array(
'Authorization: Bearer '.$arSettings["token"],
'Content-Type: application/json'
......@@ -230,8 +230,8 @@ require_once (__DIR__.'/keys.php');
$out = curl_exec($obCurl);
$info = curl_getinfo($obCurl);
static::setLog( $headers, '--==== billzCurl HEADRES:' );
static::setLog( $out, '--==== billzCurl OUT:' );
// static::setLog( $headers, '--==== billzCurl HEADRES:' );
// static::setLog( $out, '--==== billzCurl OUT:' );
if(curl_errno($obCurl)) {
$result[ 'curl_error' ] = curl_error($obCurl);
......@@ -241,7 +241,7 @@ require_once (__DIR__.'/keys.php');
}
curl_close($obCurl);
static::setLog( $result, 'billzCurl' );
// static::setLog( $result, 'billzCurl' );
}
catch(Exception $e)
......@@ -262,10 +262,22 @@ require_once (__DIR__.'/keys.php');
'error_information' => $e->getMessage(),
];
}
}
return $result;
function progress($resource,$download_size, $downloaded, $upload_size, $uploaded)
{
if($download_size > 0)
// echo $downloaded / $download_size * 100;
$percDwn = $downloaded / $download_size * 100;
echo "\r Загружено: \033[32m".$percDwn."% \033[0m [\033[36m".$downloaded."\033 из 0m/".$download_size."...";
ob_flush();
flush();
sleep(1); // just to see effect
}
}
/**
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment