I am using CakePHP 5.0.5 to write an App that connect to Strava and get running activities for users.
Strava require a webhook so that it can push update event of user activity to my app.
Strava documentation does not tell all the parameters and data of the web hook POST.
I am writing a bit of code to get all parsedBody and put in app_logs table for analysing the posted data and it structure.
However, I can’t get all data in log, due to some of the are array inside JSON !?!?
This code get the POST body:
if ($this->request->is('post')) {
$object_type = $this->request->getQuery('object_type');
$requestQuery = $this->request->getQueryParams();
$requestData = $this->request->getParsedBody();
//the input () function does not exist
//$requestJSON = $this->request->input('json_decode');
if (!is_null($object_type)){
}
$this->addLog($requestQuery);
$this->addLog($requestData);
//$this->addLog($requestJSON);
$this->set('result', 'OK');
$this->viewBuilder()->setOption('serialize', ['result']);
return;
}
This Code log the POST body into string field in app_logs table
public function addLog(mixed $content){
$logTable = $this->fetchTable('AppLogs');
$log = $logTable->newEntity(['name' => implode(', ', $content)]);
$logTable->save($log);
}
Anh this is what I get in database:
update, 1711896540, 11075006063, activity, 70175148, 257235, Array
I have read CakePHP 5 documentation, but this bit does not exist