Best way to check for deactivated twitch accounts

Best way to check for deactivated twitch accounts
0

#1

What is the best way to check for deactivated twitch accounts for the twitchTV project? In the array of users provided in the project prompt, one of them appears to be inactive(not sure if that is considered deactivated by twitch or not) while the rest are active. The way I came to this conclusion was by querying the data.status from the getJSON call to the twitch channel’s API. From what I’m seeing, all but one of the users have a status, and it appears that the one user that doesn’t has no activity on his account. All the other accounts do have activity. Is this just a coincidence and should I check for deactivation/inactivity in a different manner or am I on the right track here?
Thanks!


#2

Make an api call for a channel. The deleted and nonexistent channels will return “error” as the first key of the response. If the error is “Unprocessable Entity” the channel was deleted. If the error is “Not Found” the channel never existed. Existing channels return “stream” as the first key in the response.


#3

Thanks for the reply! I am trying to implement your advice, but when I try and console log an account that doesn’t exist or is deactivated, I can’t manage to get anything to appear in the console. Here is the code I am using:

function usrStatus(user) {
$.getJSON(‘https://api.twitch.tv/kraken/channels/’ + user, function(channel) {
console.log(channel);
});
}

usrStatus(“freecodecamp”); //works
usrStatus(“brunofin”);// doesn’t work
usrStatus(“comster404”); // doesn’t work
console.log(“HEYYYYYY”);

Why isn’t the above code returning an error or any info about the object? When I first tested something similar to this, it worked, but the function I have now isn’t working.


#4

Hi,
Instead of ‘https://api.twitch.tv/kraken/channels/’ + user try
https://api.twitch.tv/kraken/streams/’ + user

That should fix the problem.