[SOLVED] Search by game name that has space or colon doesn't work

Hello. I am working this on php page.

$myGame=‘Minecraft’; /* Set game name here */

$dataArray = json_decode(@file_get_contents_curl(‘https://api.twitch.tv/kraken/streams?limit=1&game=’ . $myGame), true);

This works for “Minecraft” which has no space or symbol, however, game name like “The Elder Scrolls: Legends” doesn’t work.

It seems it just doesn’t work when there is a space or symbol like colon

How can I fix this??


I was just using wrong variable. Solved.
Thank you very much for helps.

Have you tried to use urlencode in PHP?

Yes. it works for “The Elder Scrolls: Legends” now.
But it doesn’t work for “Senran Kagura: Peach Beach Splash”.

I did like following:

$myGame=‘Senran Kagura: Peach Beach Splash’; /* Set game name here */

$dataArray = json_decode(@file_get_contents_curl(‘https://api.twitch.tv/kraken/streams?limit=1&game=’ . urlencode($myGame)), true);

Give it double quotes on the game name.

$myGame = “Senran Kagura: Peach Beach Splash”; /* Set game name here */

$dataArray = json_decode(@file_get_contents_curl(‘https://api.twitch.tv/kraken/streams?limit=1&game=’ . urlencode($myGame)), true);

It doesn’t work…
Maybe that query can’t find the stream in that game category.

I used following:

$myGame = “Senran Kagura: Peach Beach Splash”; /* Set game name here */

$dataArray = json_decode(@file_get_contents_curl(‘https://api.twitch.tv/kraken/streams?limit=1&game=’ . urlencode($myGame)), true);

Code:

Output:
http://twitch.apiexampl.es/jajdwd_jajaja.php

I have it working with this, what sort of output/error are you getting?

JUST SOLVE. Thank you very much!

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