Get Game Image depending on Streamer Game

Hi all,

i want to create for my OBS Overlay a Box with "Whats Next + “Image of the Game”
But i really dont want to save all possible Gamecovers on my PC.
So thats my question:

How can i get with php or similar the new Gamecover from Twitch based on the Game i played?

I really tried it the whole day, but i cant get it work.

Could you help me?

Hi,

You could use the search endpoint and just loop through the games and get the image for your match.
Like https://api.twitch.tv/kraken/search/games?q=minecraft&type=suggest and then get the “box” image.

Yeah thats the whole point i dont know how :frowning:
My PHP and JSON knowledge is quite few and in other php forum they dont really help a newbie :slight_smile:

To expand slightly on the answer from @Dev, you could also get the current game your channel is playing through the Channels API and use that as your search term to the Search API. That can save you on looping at the expense of two server calls.

Just saw your follow-up, @chinty. You should check out CodeAcademy’s PHP course or PHP: The Right Way. The former is for learning the basics of the language, and the latter is a good resource for practices once you understand the language.

chinty, take a look at the example PHP I just put together for you at http://twitch.apiexampl.es/

http://twitch.apiexampl.es/gameimg.php?game=minecraft <- To see the example for results for minecraft
http://twitch.apiexampl.es/gameimg.php.txt <- To see the source code.

Then to elaborate on your request, about the game specific to you, I wrote
http://twitch.apiexampl.es/gametag.php?streamer=NAME
again, you can see the source at http://twitch.apiexampl.es/gametag.php.txt

Then I made a modified version of gameimg specifically to show you a working example using gametag.php
http://twitch.apiexampl.es/chinty.php
source: http://twitch.apiexampl.es/chinty.php.txt

(For the example I set the streamer to jcarverpoker since it was the current most popular stream online)

I apologize for the lack of comments in the code, I will get around to commenting it later. If you have any questions just shoot me a message.

The gametag.php bit could run in 1 single .php file with everything else, I just separated it for the example.

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