Viewer Counter - HELP

Hey how can I display viewers on my website?

You can use the Get Streams API to periodically poll for the current view count

This won’t work client side, due to the upcoming oAuth requirements

You will need to generate and use a Server to Server token AKA App Token

on a Server cron job.

I too have a similar issue.

For a client side webpage, I run a simple AJAX query with the payload:

type: 'GET',
url: ''+channelname,
headers: {
	'Client-ID': 'xxx_my_client_id_xxx'

I parse the response and I get channel viewer_count.

Are you saying that with the new OAuth requirement, that I can no longer do any kind of client side query to obtain viewer channel counts anymore? That I MUST Authenticate first and then pass the OAuth token to get the viewer count data I need?

Essentially Correct.

Otherwise client side you’d use implicit auth, but you don’t want to have to authenticate every visitor jsut to get the view count

What is implicit auth?
And yeah i basically don’t wanna auth every time the page loads just to get a view count.

Is there really no easier way / work around for this?

is the best solution. Make your server call the API and pass that as a variable to your Website front end

Damn I dont have a backend service for what I am trying to do. Its just a simple client side script that makes an AJAX call to the api to retrieve viewer count. :frowning: I dont really wanna make a whole backend just to support this, seems like incredible overhead.

I imagine OAuth tokens expire, so I can’t just hardcode the token once?

Correct, additionally you cannot put a oAuth token on the front end of a website, as it’s essentially a password and you should protect those.

I have a Webspace

No idea what that is, but sounds like it’s not compatible with being able to make server side calls

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