I’ve removed the link and would highly recommend you take that Pastebin down. It has your secret and an access token for Twitter included. Those are considered private information.
Your Twitch-related code works fine. I just tried it locally without issue. I’m guessing it is the Twitter-related code that isn’t working. In particular:
$tweet = creaTweet($response, $canales[$var]);
You’re passing in the entire $response object instead of $jsonResultado. That means that multiple variables in other functions could cause errors ( $pathImagen, for example).