How can I use the TwitterAPI inside of Roblox?

Hello developers!

I am trying to use the Twitter API inside Roblox and I am not sure how to go about this.

Just doing this HTTPService:GetAsync("https://api.twitter.com/2/users/by/username/oskxzr/following") will not work, because I have not supplied my credentials.

I have my API Key, Key Secret, and Bearer Token, but how do I supply these to GetAsync?

Thanks!

3 Likes

I don’t use HTTPService most of the time or the Twitter API, but in this case you’d need to use HTTPService::RequestAsync

1 Like

In the original post, I did not ask how to send a request I asked how to include extra fields:

P.S: RequestAsync is for requests but I am not requesting, I am getting which is why I supplied GetAsync in the original post.

1 Like

The StackOverFlow link has code to get you started. The only problem is Roblox doesn’t allow % which made me do all that stuff, for HTTP 401 Unauthorized. :person_facepalming:

RequestAsync is essentially the same as GetAsync just with more features, it allows you to provide a dictionary which will include the URL you are requesting, method (GET, POST, DELETE, etc.), headers, and the body.

According to the Twitter API you will need to provide your Bearer token in the headers so the api can validate the request. Here is an example on how to use RequestAsync.

HTTPService:RequestAsync is what is used to send Headers with the request, that’s where the Credentials will go. There must be something about Headers in the Twitter Api

1 Like

Twitter bearer keys have a % which roblox doesnt allow in headers. you will need a proxy (using heroku is the best way)