How to change some channel's info with javascript?

I have a problem.
I try to set “status”, “game” and “lang” using JavaScript API and the callback returns the same (not changed at all) configuration. I just don’t understand, what did I do wrong???

Here is my code:
Twitch.api({method: '/channels/' + login, verb: 'PUT', params: { channel: { status: document.getElementById("title").value, game: document.getElementById("activity").value, language: document.getElementById("language").value } }}, function(error, channel) { if (error) { console.log(error); } }); if ($('language-mode').prop("checked")) { Twitch.api({method: '/channels/' + login, verb: 'PUT', params: { channel: { broadcaster_language: document.getElementById("language").value } }}, function(error, channel) { if (error) { console.log(error); } }); }
And the response returns just the same information. Not changed data.
What is wrong with my code???

You need channel_editor for the update endpoint. Was that specified correctly during your login step?

Yes, it was. I get this permition.
Twitch.login({ scope: ['user_read', 'channel_read', 'channel_editor'] });

Do you get an error? What does it say?

No, I get status. And it is… empty. Like empty. Nothing is in output. M.b. I get it somehow wrong… I just don’t know how to get status in a right way… I tryed to do it like “console.log(status)”, but not shure if it is correct…

What is the HTTP code? 200? 400? 404?

It’s “200”. “OK”.

Are you sure the XHR the browser sends is a PUT?

If you’re using the CDN URL for the Twitch SDK (https://ttv-api.s3.amazonaws.com/twitch.min.js), it’s outdated and doesn’t support the verb option, so your request is being sent as a GET. Download the one on github.

You can also use _method: 'PUT' inside params. Here’s an example using both.

Ow… I get it… Yeah. I really use https://ttv-api.s3.amazonaws.com/twitch.min.js… It’s clear now, why did I failed before…

I’ll try to use your link. TY.

Wooow! TY so much!!! It finally works! I add “_method: ‘PUT’” to parameters and now it’s good! GG WP!

Buuut…
I still cannot set language and broadcaster_language to the channel… How can I change those?

I don’t believe you can change those. The supported parameters are shown in the documentation.

So those are ONLY editable??? Wow. Sad. I hoped, it’s just an exemple…

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