Using curl in operational_hooks.php

Matthijs

Member
I would like to user curl in operational_hooks.php (need to trigger asynchronous).
I have to coding below. If I run this code outside dadabik, all works fine.
But it does not work in operational_hooks.php.
What could be the reason?


$hooks['mslb_ads']['insert']['after'] = 'dadabik_ads';
$hooks['mslb_ads']['update']['after'] = 'dadabik_ads';
function dadabik_ads($id)
{
$target_url = "[valid url]";
$ch = curl_init($target_url);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
curl_close($ch);
}


Your current DaDaBIK version​

You are using DaDaBIK version 11.10-Elba monthly, installed on 13-07-2023 (installation code: 18828644e443ac0e33), the latest version of DaDaBIK is 11.10-Elba released on 13-07-2023

You are running the latest release of DaDaBIK

In case you want to upgrade to a more powerful edition (from Pro to Enterprise/Platinum, from Enterprise to Platinum) please contact us.

System info​

PHP Version: 8.1.21

mysql version: 10.6.14-MariaDB

Web server: Apache/2

Client: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:109.0) Gecko/20100101 Firefox/116.0

URL installation: https://mslb.nl/dadabik/
 

eugenio

Administrator
Staff member
Hello,
I haven't checked your code but if it normally works, it must work also as operational hook.
Do you get any error? What do you mean with "outside dadabik"? I would create a test php script inside the dadabik folder and test the code there.

Best,
 
Top