Hello I am trying to get new follower data(id,name etc.) via javascript. I want to get notification about new follower from server. I do not know much I just wanted to do it myself. Looks like I did a mistake. Here is my code:
function getFollower(){
var xhttp = new XMLHttpRequest();
xhttp.open("POST", "https://api.twitch.tv/helix/webhooks/hub", true);
xhttp.setRequestHeader("Content-type", "application/json");
var jsondata;
xhttp.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 202) {
//on doc that says it will send a 202 empty body and yes it does
jsondata = JSON.stringify(xhttp.responseText);
console.log(jsondata);
document.getElementById("widget").innerHTML = "test "+jsondata;
}
if (this.readyState == 4 && this.status == 400) {
document.getElementById("widget").innerHTML = this.responseText;
}
};
xhttp.setRequestHeader("Client-ID", "xxxxxxxxxxxxxxxxxxxxxxxxxx"); // mysecret
var data = JSON.stringify({"hub.mode":"subscribe","hub.topic":"https://api.twitch.tv/helix/users/follows?to_id=XXXXXXX&first=1","hub.callback":"http://100.xx.xx.xx:port/savetodb.php"});
xhttp.send(data);
}
“http :// 100.xx.xx.xx:port” is ip and I can access it anywhere. PHP page saves something to MYSQL db to see if that works. What am I missing here ?
if I get 202 that means, I will get response right however I do not get anything. My server listens a specific port which is not 80. But still I put my port to callback url. Is that a problem ?
Hey I saw your post on how to find what channels someone’s following or find out who someone is following could you help me with that?Here’s my email REMOVED If you could help me with that I would be forever grateful
It’s unwise to post you email publicly. I have removed it.
Please open a thread on the forums if you require help. Rather than jumping on someone elses thread. Especially when the issue you describe is totally unrelated to this thread
I’m sorry it’s just hard to get a hold of someone on these forums since you Can’t directly message them. Do you think twitch will add this feature in the future?