PHP to webhook

I have a secure php script that when is run, it sends a variable to a webhook automation. I have got the webhook to trigger, but can not send the php variables.

$dataf = "hello";
$curl_handle = curl_init();
curl_setopt($ch, CURLOPT_POSTFIELDS, $dataf);
curl_setopt($curl_handle, CURLOPT_URL, "https://*********.org:8123/api/webhook/-***********ccJuejG");
curl_exec($curl_handle);
curl_close($curl_handle);
$dataf= "hello";
$curl_handle = curl_init();
curl_setopt($curl_handle, CURLOPT_URL, "https://*********.org:8123/api/webhook/-***********ccJuejG?dataf=".$dataf);
curl_exec($curl_handle);
curl_close($curl_handle);

and on the trigger side

- id: '****************'
  alias: PHS incoming email
  description: ''
  trigger:
  - platform: webhook
    allowed_methods:
    - POST
    - PUT
    - HEAD
    - GET
    local_only: false
    webhook_id:********TccJuejG
  condition:
  - condition: zone
    entity_id: device_tracker.*****
    zone: zone.*****
  action:
  - service: tts.speak
    data:
      cache: true
      media_player_entity_id: media_player.all_speakers
      message: Incoming Pacific HotShots email {{trigger.data.dataf}
    target:
      entity_id: tts.google_en_com_au
  mode: single

I take it, it is not possible?

I think the variable needs to be json

Pretty sure you are missing:

curl_setopt($curl_handle, CURLOPT_POST,1);

As for the actual data:

$arr['data'] = "Whatever data I want to be available in HomeAssistant";
curl_setopt($curl_handle, CURLOPT_POSTFIELDS, $arr);
1 Like

Thanks mate… didnt notice I missed the $curl_handle, changed that and it worked straight away… im a dumb dumb sometimes… haha

1 Like