Webhook when user starts stream with empty data on body


#1

Hello there, I’m having a problem on my application.

I’ve a webhook to when someone start to stream on twitch.
Then, twitch send me a http request.
The problem is, that sometimes the data from the body of the request sometimes have information and sometimes doesn’t.

Request examples

No information on data

INFO - 2019-08-26 11:21:14 --> array (
    'type' => 'post',
    'data' => 
    stdClass::__set_state(array(
        'data' => 
    array (
    ),
    )),
    'headers' => 
    array (
    'Content-Type' => 'application/json; charset=utf-8',
    'Host' => 'my.domain.com',
    'User-Agent' => 'Go-http-client/1.1',
    'Connection' => 'close',
    'Content-Length' => '11',
    'Link' => '; rel="hub", ; rel="self"',
    'Twitch-Notification-Id' => '18c3753b-e72c-524b-b0d3-20e60a355f1c',
    'Twitch-Notification-Timestamp' => '2019-08-26T14:21:13Z',
    'Accept-Encoding' => 'gzip',
    ),
)

Information on data

INFO - 2019-08-26 11:47:51 --> array (
    'type' => 'post',
    'data' => 
    stdClass::__set_state(array(
        'data' => 
    array (
        0 => 
        stdClass::__set_state(array(
            'game_id' => '513143',
            'id' => '35436702144',
            'language' => 'en',
            'started_at' => '2019-08-26T13:48:10Z',
            'tag_ids' => 
        array (
            0 => '6ea6bca4-4712-4ab9-a906-e3336a9d8039',
        ),
            'thumbnail_url' => 'https://static-cdn.jtvnw.net/previews-ttv/live_user_mutafuzz-{width}x{height}.jpg',
            'title' => '[BR/EN] :ooooo | @mutafuzz1',
            'type' => 'live',
            'user_id' => '106354514',
            'user_name' => 'mutafuzz',
            'viewer_count' => 1,
        )),
    ),
    )),
    'headers' => 
    array (
    'Content-Type' => 'application/json; charset=utf-8',
    'Host' => 'my.domain.com',
    'User-Agent' => 'Go-http-client/1.1',
    'Connection' => 'close',
    'Content-Length' => '367',
    'Link' => '; rel="hub", ; rel="self"',
    'Twitch-Notification-Id' => '7c66efce-b517-5705-8e4e-ba1346412910',
    'Twitch-Notification-Timestamp' => '2019-08-26T14:47:50Z',
    'Accept-Encoding' => 'gzip',
    ),
)

My problem/doubt is, this should happen??


#2

Where it sends ‘{data:[]}’ that means the stream has ended and gone offline

as per


#3

A little help them, how I can know which user has gone offline if I don’t receive any info?


#4

Disambiguating Payloads

To easily disambiguate notification payloads from each other (especially for “stream down” events), you can do either of following:

  • Inspect the topic string (found in the link header).
  • Use a different callback URL for each subscription; e.g., by changing the path or the query parameters.

#5

I’m receiving this message in my application when I start a stream

{
    "type": "get",
    "data": {
        "hub_mode": "denied",
        "hub_reason": "exceeded maximum number of allowed subscriptions",
        "hub_topic": "https:\/\/api.twitch.tv\/helix\/streams?user_id=167238651"
    },
    "headers": {
        "Content-Type": "",
        "Host": "my.domain.com",
        "User-Agent": "Go-http-client\/1.1",
        "Connection": "close",
        "Accept-Encoding": "gzip"
    }
}

This means that I’ve exceeded the maximum number of subscriptions on my account and I need to request to increase that limit?

I think I need to, but I’m asking this just to make sure.
One thing I’ve observed is that the request come using the verb GET and not POST.


#6

More likely you did something wrong…

You can use

To check your active subscriptions.
You are allowed to subscribe to each topic 3 times

Limits: Each client ID can have at most 10,000 subscriptions. Also, you can subscribe to the same topic at most 3 times.

I doubt you have raised 10k subscriptions but you’ve done something wrong

So you’d subscribe to https://api.twitch.tv/helix/streams?user_id=167238651 once and renew it every lease_seconds ish


closed #7

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.