How To Set Title?

Using the API I made a Java based notifier, which displays “soandso just followed!” anytime the API updates.
But I recently added the ability to change the title and to view the title: but in order to change the title, I had to resort to using chat (pircbot) and using Nightbot to set the title. Some users don’t use Nightbot, so do you guys know either how Nightbot does it, or how I could do it?

EDIT: I have researched even more: and it seems I would need to do an HTTP request consisting of:
"{\"channel\":{\"status\":"test channel status\",\"game\":\"Minecraft\"}}"

And then I would need to do a data output stream. This all I can do: my problem is getting Twitch.tv authorization to allow the request through. Any help would be appreciated :smiley:

##Register your application ##
Twitch settings -> connections -> register application

Authorize your application

You need the channel you’re altering to authorize your application with the scope channel_editor.
The user needs to go to https://api.twitch.tv/kraken/oauth2/authorize?response_type=token&client_id=CLIENT_ID&redirect_uri=REDIRECT_URI&scope=channel_editor and fill in their password. (Your ID and redirect URI need to match those registered to your application.) The access token that you need will be sent as a parameter to REDIRECT_URI.
##Make the request##
You need to send your access token and new title/game data as headers in your request. Using cURL, it looks like this:
curl -H 'Accept: application/vnd.twitchtv.v2+json' -H 'Authorization: OAuth <access_token>' -d "channel[status]=New+Status!&channel[game]=New+Game!" -X PUT https://api.twitch.tv/kraken/channels/CHANNEL

You can always check here for more information!

1 Like

Ah I saw that online aswell, but that was for .net if I remember right… I also found an example for c, but no beans on java. So I researched how to http request with java, but this still is inconclusive because I don’t understand http yet. But I will look it up when I get the time. The information you gave will allow me to solve my problem, thanks! Any other tips? Should I use something other than java?

I don’t have a lot of experience with Java, but it looks like cURL has a java implementation here. I’d recommend javascript to anyone, but I don’t know what you’re trying to do, so I can’t really make a recommendation. Good luck!

Well, I have done just about all the research I have time for, here is my next question:
If if have a java application: how can I get the java application to verify not only with my account, but with who ever clicks the button.

So apparently: the response is sent to http://localhost
So now, how do I grab this response!

Well I figured it out using: http://stackoverflow.com/questions/2793150/how-to-use-java-net-urlconnection-to-fire-and-handle-http-requests

Now I found that the only way to post from a non web-browser is password grant flow, and this requires SPECIAL permission from the API team. No wonder I kept getting 403’s.