E
E
Evrooo2019-04-02 17:03:44
Bitrix24
Evrooo, 2019-04-02 17:03:44

Bitrix24 incoming webhooks enlighten?

Set up an incoming webhook with access to Time Tracking (timeman).
You need to get a report on the working hours of employees.
I am using code:

function writeToLog($data, $title = '') {
 $log = "\n------------------------\n";
 $log .= date("Y.m.d G:i:s") . "\n";
 $log .= (strlen($title) > 0 ? $title : 'DEBUG') . "\n";
 $log .= print_r($data, 1);
 $log .= "\n------------------------\n";
 file_put_contents(getcwd() . '/hook.log', $log, FILE_APPEND);
 return true;
}

 $queryUrl = 'https://****.bitrix24.ru/rest/10/****************/timeman.timecontrol.reports.get';
 $queryData = http_build_query(
   	array(
     'fields' =>array(
      'USER_ID' => 29,
    		'YEAR' => 2019,
    		'MONTH' => 3,
      ),
   	)
  );

 $curl = curl_init();
 curl_setopt_array($curl, array(
     CURLOPT_SSL_VERIFYPEER => 0,
     CURLOPT_POST => 1,
     CURLOPT_HEADER => 0,
     CURLOPT_RETURNTRANSFER => 1,
     CURLOPT_URL => $queryUrl,
     CURLOPT_POSTFIELDS => $queryData,
   )
 );

 $result = curl_exec($curl);
 curl_close($curl);

 $result = json_decode($result, 1);
 writeToLog($result, 'result');

 var_dump($result);

As a result, I get a report for the current day.
spoiler

array(2) {
["result"]=>
bool(false)
["time"]=>
array(6) {
["start"]=>
float(1554213687.1079)
["finish"]=>
float(1554213687.1647)
["duration"]=>
float(0.056741952896118)
["processing"]=>
float(0.003511905670166)
["date_start"]=>
string(25) "2019-04-02T17:01:27+03:00"
["date_finish"]=>
string(25) "2019-04-02T17:01:27+03:00"
}
}

What am I doing wrong? Maybe I'm using the wrong method? According to the description, this
The method for obtaining a report on identified absences.

The selected employee has absences in March.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Anna_Graem, 2019-08-12
@Anna_Graem

Probably already irrelevant, but - you are passing the wrong array of parameters.

$queryData = http_build_query(
   	array(
     'fields' =>array(
      'USER_ID' => 29,
    		'YEAR' => 2019,
    		'MONTH' => 3,
      ),
   	)
  );

On this
$queryData = http_build_query(
array(
'USER_ID' => 29,
'YEAR' => 2019,
'MONTH' => 3,
   	)
  );

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question