# Get new follower notifications

**URL:** <https://discuss.dev.twitch.com/t/get-new-follower-notifications/24951>\
**Category:** API\
**Created:** [April 13, 2020, 9:27am UTC](https://discuss.dev.twitch.com/t/get-new-follower-notifications/24951 "2020-04-13T09:27:11Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![metzamor](https://avatars.discourse-cdn.com/v4/letter/m/e36b37/32.png) [@metzamor](https://discuss.dev.twitch.com/u/metzamor)\
**Post date:** [April 13, 2020, 9:27am UTC](https://discuss.dev.twitch.com/t/get-new-follower-notifications/24951/1 "2020-04-13T09:27:11Z")

</div>

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 ?

---

<div class="post-metadata">

**Author:** ![Dist](https://d3ovvz0v2ajtpu.cloudfront.net/user_avatar/discuss.dev.twitch.com/dist/32/7192_2.png) [@Dist](https://discuss.dev.twitch.com/u/Dist)\
**Post date:** [April 13, 2020, 10:50am UTC](https://discuss.dev.twitch.com/t/get-new-follower-notifications/24951/2 "2020-04-13T10:50:36Z")

</div>

Have you correctly set up a GET handler on your callback URL to deal with the `hub.challenge`?

---

<div class="post-metadata">

**Author:** ![metzamor](https://avatars.discourse-cdn.com/v4/letter/m/e36b37/32.png) [@metzamor](https://discuss.dev.twitch.com/u/metzamor)\
**Post date:** [April 13, 2020, 11:59am UTC](https://discuss.dev.twitch.com/t/get-new-follower-notifications/24951/3 "2020-04-13T11:59:50Z")

</div>

No, I have no `hub.challenge` how should I prepare that ?

---

<div class="post-metadata">

**Author:** ![BarryCarlyon](https://d3ovvz0v2ajtpu.cloudfront.net/user_avatar/discuss.dev.twitch.com/barrycarlyon/32/253_2.png) [@BarryCarlyon](https://discuss.dev.twitch.com/u/BarryCarlyon)\
**Post date:** [April 13, 2020, 12:02pm UTC](https://discuss.dev.twitch.com/t/get-new-follower-notifications/24951/4 "2020-04-13T12:02:13Z")

</div>

Webhooks work as follows

1. You POST to make a sub, twitch replies 202
2. Twitch sends a GET request to your Callback with a `hub.challenge` which in PHP presents as `$_POST['hub_challenge']` iirc
3. You echo back that challenge
4. When data occurs Twitch POSTs back to your with JSON data in the body (`file_get_contents` on `php://input`)

---

<div class="post-metadata">

**Author:** ![metzamor](https://avatars.discourse-cdn.com/v4/letter/m/e36b37/32.png) [@metzamor](https://discuss.dev.twitch.com/u/metzamor)\
**Post date:** [April 13, 2020, 1:23pm UTC](https://discuss.dev.twitch.com/t/get-new-follower-notifications/24951/5 "2020-04-13T13:23:54Z")

</div>

> [@BarryCarlyon](#):
>
> $\_POST[‘hub\_challenge’]

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 ?

---

<div class="post-metadata">

**Author:** ![BarryCarlyon](https://d3ovvz0v2ajtpu.cloudfront.net/user_avatar/discuss.dev.twitch.com/barrycarlyon/32/253_2.png) [@BarryCarlyon](https://discuss.dev.twitch.com/u/BarryCarlyon)\
**Post date:** [April 13, 2020, 1:25pm UTC](https://discuss.dev.twitch.com/t/get-new-follower-notifications/24951/6 "2020-04-13T13:25:57Z")

</div>

Generally speaking you want to have your callback behind SSL/HTTPs, which requires a domain name (this may become a requirement at some point)

You seem to be using an IP address. So the normal url is

> [http://127.0.0.1:8001](http://127.0.0.1:8001)

For example.

> protcol://ip\_address:port

If it’s not working check that your Callback URL is web accessable and consult your server access/error logs and your firewall

---

<div class="post-metadata">

**Author:** ![Dist](https://d3ovvz0v2ajtpu.cloudfront.net/user_avatar/discuss.dev.twitch.com/dist/32/7192_2.png) [@Dist](https://discuss.dev.twitch.com/u/Dist)\
**Post date:** [April 13, 2020, 1:30pm UTC](https://discuss.dev.twitch.com/t/get-new-follower-notifications/24951/7 "2020-04-13T13:30:29Z")

</div>

You can use the Get Webhook Subscriptions endpoint to check if the subscription has been created or not [https://dev.twitch.tv/docs/api/reference#get-webhook-subscriptions](https://dev.twitch.tv/docs/api/reference#get-webhook-subscriptions)

If the subscription isn’t shown there, then there is an issue with your side of the subscription process.

---

<div class="post-metadata">

**Author:** ![Khal\_Zone](https://d3ovvz0v2ajtpu.cloudfront.net/user_avatar/discuss.dev.twitch.com/khal_zone/32/8342_2.png) [@Khal\_Zone](https://discuss.dev.twitch.com/u/Khal_Zone)\
**Post date:** [April 14, 2020, 5:09pm UTC](https://discuss.dev.twitch.com/t/get-new-follower-notifications/24951/8 "2020-04-14T17:09:31Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![BarryCarlyon](https://d3ovvz0v2ajtpu.cloudfront.net/user_avatar/discuss.dev.twitch.com/barrycarlyon/32/253_2.png) [@BarryCarlyon](https://discuss.dev.twitch.com/u/BarryCarlyon)\
**Post date:** [April 14, 2020, 5:11pm UTC](https://discuss.dev.twitch.com/t/get-new-follower-notifications/24951/9 "2020-04-14T17:11:33Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Khal\_Zone](https://d3ovvz0v2ajtpu.cloudfront.net/user_avatar/discuss.dev.twitch.com/khal_zone/32/8342_2.png) [@Khal\_Zone](https://discuss.dev.twitch.com/u/Khal_Zone)\
**Post date:** [April 14, 2020, 5:15pm UTC](https://discuss.dev.twitch.com/t/get-new-follower-notifications/24951/10 "2020-04-14T17:15:07Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![BarryCarlyon](https://d3ovvz0v2ajtpu.cloudfront.net/user_avatar/discuss.dev.twitch.com/barrycarlyon/32/253_2.png) [@BarryCarlyon](https://discuss.dev.twitch.com/u/BarryCarlyon)\
**Post date:** [April 14, 2020, 5:18pm UTC](https://discuss.dev.twitch.com/t/get-new-follower-notifications/24951/11 "2020-04-14T17:18:30Z")

</div>

Please open another thread with the issue you are having. Please stop replying to this thread it is off topic to this thread.

---

<div class="post-metadata">

**Author:** ![system](https://d2opxh93rbxzdn.cloudfront.net/original/2X/0/05909729875cce3b53e59d5561c4d23bb14948fc.png) [@system](https://discuss.dev.twitch.com/u/system)\
**Post date:** [May 14, 2020, 5:18pm UTC](https://discuss.dev.twitch.com/t/get-new-follower-notifications/24951/12 "2020-05-14T17:18:31Z")

</div>

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