Please help me.
I’m trying to set up a callback to subscribe to EventSub.
I am using framework yii2 (PHP).
What am I doing wrong?
I test my callback and get the following:
Summary
PS C:\Users\ma110y> twitch event trigger update-redemption -F https://tagged-play.ru/twitch-callback -s c3eb4dc7c6da0ad20397fbaa244a04446c76e9d3df71b7c99fd1057b7102729c
✔ Request Sent. Received Status Code: 200
✔ Server Said: null
{"subscription":{"id":"137d104b-68eb-b00c-e322-b8961900cc41","status":"enabled","type":"channel.channel_points_custom_reward_redemption.update","version":"1","condition":{"broadcaster_user_id":"17390441"},"transport":{"method":"webhook","callback":"null"},"created_at":"2023-01-18T21:28:25.1561829Z","cost":0},"event":{"id":"137d104b-68eb-b00c-e322-b8961900cc41","broadcaster_user_id":"17390441","broadcaster_user_login":"testBroadcaster","broadcaster_user_name":"testBroadcaster","user_id":"40725345","user_login":"testFromUser","user_name":"testFromUser","user_input":"Test Input From CLI","status":"unfulfilled","reward":{"id":"8eca1920-3776-eb6c-dbda-61d044f67e09","title":"Test Reward from CLI","cost":150,"prompt":"Redeem Your Test Reward from CLI"},"redeemed_at":"2023-01-18T21:28:25.1561829Z"}}
PS C:\Users\ma110y>
On my site I see fallowing:
Summary
[event] => stdClass Object
(
[id] => 137d104b-68eb-b00c-e322-b8961900cc41
[broadcaster_user_id] => 17390441
[broadcaster_user_login] => testBroadcaster
[broadcaster_user_name] => testBroadcaster
[user_id] => 40725345
[user_login] => testFromUser
[user_name] => testFromUser
[user_input] => Test Input From CLI
[status] => unfulfilled
[reward] => stdClass Object
(
[id] => 8eca1920-3776-eb6c-dbda-61d044f67e09
[title] => Test Reward from CLI
[cost] => 150
[prompt] => Redeem Your Test Reward from CLI
)
[redeemed_at] => 2023-01-18T21:28:25.1561829Z
)
Next, I register a webhook and get the following:
Summary
array(4) {
["data"]=>
array(1) {
[0]=>
array(8) {
["id"]=>
string(36) "90e92aed-b2d2-4b88-963d-19e564a56df1"
["status"]=>
string(37) "webhook_callback_verification_pending"
["type"]=>
string(14) "channel.update"
["version"]=>
string(1) "1"
["condition"]=>
array(1) {
["broadcaster_user_id"]=>
string(9) "798748369"
}
["created_at"]=>
string(30) "2023-01-18T21:21:40.969961007Z"
["transport"]=>
array(2) {
["method"]=>
string(7) "webhook"
["callback"]=>
string(38) "https://tagged-play.ru/twitch-callback"
}
["cost"]=>
int(0)
}
}
["total"]=>
int(1)
["max_total_cost"]=>
int(10000)
["total_cost"]=>
int(0)
}
on my server i see this:
Summary
stdClass Object
(
[subscription] => stdClass Object
(
[id] => 90e92aed-b2d2-4b88-963d-19e564a56df1
[status] => webhook_callback_verification_pending
[type] => channel.update
[version] => 1
[condition] => stdClass Object
(
[broadcaster_user_id] => 798748369
)
[transport] => stdClass Object
(
[method] => webhook
[callback] => https://tagged-play.ru/twitch-callback
)
[created_at] => 2023-01-18T21:21:40.969961007Z
[cost] => 0
)
[challenge] => 7oju4NLCrEwRNYgHNVAzYXf_brHJR4J5iNDaiHZI2Qs
)
But when I send /helix/eventsub/subscriptions, I get webhook_callback_verification_failed
Summary
{
"total": 1,
"data": [
{
"id": "90e92aed-b2d2-4b88-963d-19e564a56df1",
"status": "webhook_callback_verification_failed",
"type": "channel.update",
"version": "1",
"condition": {
"broadcaster_user_id": "798748369"
},
"created_at": "2023-01-18T21:21:40.969961007Z",
"transport": {
"method": "webhook",
"callback": "https://tagged-play.ru/twitch-callback"
},
"cost": 0
}
],
"max_total_cost": 10000,
"total_cost": 0,
"pagination": {}
}
My code:
Summary
public function actionIndex()
{
\Yii::$app->response->format = Response::FORMAT_JSON;
\Yii::$app->response->statusCode = 200;
$folder = \Yii::getAlias('@app/runtime/');
file_put_contents($folder . '/payload.txt', file_get_contents('php://input'), FILE_APPEND);
$incoming_payload = json_decode(file_get_contents('php://input'));
file_put_contents($folder . '/payload_json.txt', '<pre>' . print_r($incoming_payload, true). '</pre>', FILE_APPEND);
$headers = '<pre>' . print_r(getallheaders(), true) . '</pre>';
file_put_contents($folder. '/' .time() . '_HEADERS.txt', $headers);
if(isset($_GET) && !empty($_GET)) {
$get = '<pre>' . print_r($_GET, true) . '</pre>';
file_put_contents($folder. '/' .time() . '_GET.txt', $get);
}
if(isset($_POST) && !empty($_POST)){
$post = '<pre>' . print_r($_POST, true) . '</pre>';
file_put_contents($folder. '/' .time() . '_POST.txt', $post);
}
}
Callback link - https://tagged-play.ru/twitch-callback
I return 200 code as required by the documentation and do not output/send anything in response.
I have an ssl certificate and port 443 is available. What am I doing wrong?