Understanding Trigger Callbacks
  • I'm trying to understand how the trigger callbacks work. I have a trigger on a place with a callback url that I'm trying to record the json that is passed to it. The actual callback is working (I can run it with trigger/run/:id) but I'm not understanding how the json is passed to the callback. I would like to take some of the info from the json and record it to a db. The php code looks something like this:

    // Check connection
    if (mysqli_connect_errno())
      echo "Failed to connect to MySQL: " . mysqli_connect_error();
    // Grabs the json here
    $request_body = file_get_contents('php://input');
    $json = json_decode($request_body, true);
    $name = $json["post"]["user"]["user_id"];

    $sql = "INSERT INTO table1 VALUES (NULL, '$name')";
    $result = mysqli_query($con,"SELECT * FROM table1");
    while($row = mysqli_fetch_array($result))
      echo $row['id'] . ". User: " . $row['username'];
      echo "<br>";

    I'm assuming when the trigger is run, the json is passed to the callback but I'm not getting any records showing. Any help understanding how it works is appreciated!

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!