【问题标题】:Twitch title change via api通过 api 更改 Twitch 标题
【发布时间】:2017-07-24 16:50:09
【问题描述】:

我有一个用于 twitch 的小型聊天机器人,我现在想创建一个可以更改流标题的功能。 我的功能目前看起来是这样的:

public changeTitle = (new_title: string, callback: any): void => {
    let t = this;
    let request = require('request');
    request.get("https://api.twitch.tv/kraken/channels/" + this.settings.current_channel + "?client_id="+this.settings.clientId, { json: true }, function (err, res) {
        if (!err && res.statusCode === 200) {
            let current_title = res.body.status;
            console.log(current_title);
            let request2 = require('request');
            let options = {
                url: "https://api.twitch.tv/kraken/channels/"+t.settings.current_channel+"?channel[status]="+current_title+new_title,
                headers: {
                    "Authorization": "OAuth "+t.settings.clientId,
                    "Accept": "application/vnd.twitchtv.v2+json"
                }
            };
            request2.put(options, (error: Error, response: any, body: any): void => {
                console.log("Title changed?");
            });
        }
    });
};

在 console.log(current_title) 我可以看到当前的流标题。 在 console.log("Title changed?") 之后什么也没发生。 我收到错误 410 GONE。所以不再支持我更改标题的方式。 有人可以告诉我如何更改标题吗?

提前致谢:)

【问题讨论】:

    标签: api twitch http-status-code-410


    【解决方案1】:

    这似乎被Update Channel 覆盖

    具体来说,而不是 channel[status] 仅使用 status 作为查询参数。

    let options = {
                url: "https://api.twitch.tv/kraken/channels/"+t.settings.current_channel+"?status="+new_title,
                headers: {
                    "Authorization": "OAuth "+t.settings.clientId,
                    "Accept": "application/vnd.twitchtv.v2+json"
                }
    

    您还需要channel_editor 范围才能在给定频道上使用它。

    【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2014-02-09
    • 1970-01-01
    • 2021-09-28
    • 2012-06-10
    • 1970-01-01
    • 2019-06-05
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多