Webhooks and command line together?


#1

Hello,

I made a simple C++ program which gets follower data of a user. Normally I use Windows10’s Command Line to see what will happen before I use it in my C++ code. My current problem was getting new follower. I use GET for follower data but from doc I found this for this purpose I should use Webhooks and POST method. Or I understood it wrong.

Source: https://dev.twitch.tv/docs/api/webhooks-reference/

This Code works for GET data and I made a similiar call from C++ code:
curl -X GET https://api.twitch.tv/helix/users/follows?to_id=user_id -H Client-ID:client_id -s
Result:
{"total":0,"data":[],"pagination":{}}
My request on Command Line:
curl -d "hub.callback=__IDK__&hub.mode=subscribe&hub.topic=__IDK__" https://api.twitch.tv/helix/webhooks/hub -H "Client-ID:__APPID__"
Result:
{"error":"Bad Request","status":400,"message":"hub.topic unsupported topic"}

Notes:
1- Looks like, post is correct but that can not parse hub.topic 's URL data which should be: https://api.twitch.tv/helix/users/follows?first=1&to_id=1337 - from doc page
2- I do not know how should hub.callback work. Can I use this in C++ ???

What should I do ?


#2

Webhooks require you to host a server that listens on the callback URL for requests from Twitch when there are new notifications for the topic you’re subscribed to. So as to if you can do this in C++, the answer will be yes if you can host a web server in C++, if you can’t host a web server in that then no, webhooks wont work.


#3

Thanks for the answer, I was afraid of that, now is that possible to get a new follower without that ? Example get only 1 user with GET method and order by follow time desc (nearest date).


#4

You simply use the Get User Follows endpoint: https://dev.twitch.tv/docs/api/reference/#get-users-follows

Use the params you want, and just keep making requests once a minute, or however often you want to check for new followers (keep in mind the API uses caching so more frequently than once a minute may just waste requests).


#5

Yes indeed I was trying that. The problem is I can not use GET “http://…/follows?first=1”. It gives error.

Code:
curl -X GET https://api.twitch.tv/helix/users/follows?first=1&to_id=user_id -H Client-ID:client_id -s

Result:
{“error”:“Unauthorized”,“status”:401,“message”:“Must provide a valid Client-ID or OAuth token”}‘firzst’ is not recognized as an internal or external command,
operable program or batch file.

When I put first parameter I get this result. But If I remove it I get normal result.


#6

As documented:

https://api.twitch.tv/helix/users/follows?to_id=user_id&first=1

curl -H 'Client-ID: uo6dggojyb8d6soh92zknwmi5ej1q2' \
-X GET 'https://api.twitch.tv/helix/users/follows?to_id=user_id&first=1'

In your paste you have a -s for some reason, and lacking a space between client-id: and the client_id.

You seem to have something else going on causing an issue due to

‘firzst’ is not recognized as an internal or external command,
operable program or batch file.

is off output for cURL


#7

Nope, thats another result I put mistakenly. I solved the problem.

Problem Solved By adding outside of URL double qoutes("")

curl -H "Client-ID: client_id" -X GET "https://api.twitch.tv/helix/users/follows?to_id=user_id&first=100"

Note that first_>min20max100
Since windows’ cmd’s own issues does not cover the topic they did not mention it.

1- At least windows10 Command Line should use double qoutes ("") for CURL calls which contain & expression.
2- Space between Clien-ID: client_id does not matter.

Thanks for the interest.:blush: