<?php
$client = '';
$token = '';
$user_id= '';
$callback = '';
$secret = '';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://api.twitch.tv/helix/eventsub/subscriptions');
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'Content-Type: application/json',
'Client-ID: ' . $client,
'Authorization: Bearer ' . $token
));
curl_setopt($ch, CURLOPT_POST, 1);
$payload = array(
'type' => 'stream.online',
'version' => '1',
'condition' => array(
'broadcaster_user_id' => $user_id
),
'transport' => array(
'method' => 'webhook',
'callback' => $callback,
'secret' => $secret
)
);
print_r($payload);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($payload));
curl_exec($ch);
Successfully created a subscription request for me
Edit:
Earlier I copy/pasted your “broken header” but didn’t notice you put Accept where it should be Content-Type