Json returning NULL

So locally, everything is working great, but now that I uploaded it to my web host its not working anymore.

Please help me I am loosing my mind, I’ve tried doing

$clientId = “myid”;
$json_array = json_decode(file_get_contents('https://api.twitch.tv/kraken/streams?channel=’.$channelname.’?cliend_id=’$cliendid),true);

Full code of getStream
http://pastebin.com/XYHdDuzk

On line six you have the following

file_get_contents('https://api.twitch.tv/kraken/streams&channel='.$channelname.'?client_id'.$clientId);

this should be

file_get_contents('https://api.twitch.tv/kraken/streams?channel='.$channelname.'&client_id'.$clientId);

Just realized I pasted wrong code, will give that a try.
Still getting null.

What is the output of file_get_contents('https://api.twitch.tv/kraken/streams?channel='.$channelname.'&client_id'.$clientId)?

On a localhost it shows info I need, but on host nope.
http://www.chanceity.com/stream.html
nothing there.
Using ipage for domain/host.

Try this: https://pastebin.com/KLaKTtkH and post the results.

I separate the file_get_content and json_decode so you can see the results in between. Some other changes are noted as comments.

bool(false) NULL is the result.
Guess api is returning nothing.

I just tried my files on free host, and guess what, its somewhat working. It does show random stream.

Sounds like your web hosting provider has disabled file_get_contents from retrieving data from external URLs. They commonly do this for security.

I’d recommend looking into during cURL: http://codular.com/curl-with-php

1 Like

Uh I have no idea how to use curl yet, thanks for answers and all the help guys.

THANK YOU SO MUCH, IT IS WORKING NOW HOLY F""""
I literally spent 5 hours trying to fix this, thanks a lot!