- Home /
Twitter SDK for Unity: Bad Authentication Data, error code 215
So i am simply trying to get the user's name. Not the screen_name, just the name that the user could change constantly. According to the docs, i could get it by retrieving the User Object which contains all the user's data. The problem here is whenever i try to retrieve it using ("https://api.twitter.com/1.1/users/show.json?screen_name=userName"), i always get the following error: {"errors":[{"code":215,"message":"Bad Authentication data."}]}.
Here i am using Unity SDK. Which after authentication gives me access to userName, authToken, and id.
i can't find anything useful on the internet regarding this, since using Twitter API in a game is very rare.
This is the code that i am using at the moment:
IEnumerator GetDisplayName(string userID)
{
using (WWW www = new WWW("https://api.twitter.com/1.1/users/show.json?screen_name=" + userID))
{
yield return www;
string json = www.text;
JsonUtility.FromJson<WWW>(json);
yield return www;
foreach (var item in json)
{
Debug.Log(www.text);
}
}
}
Note: i call this function after i successfully authenticate.
So is it even possible to do this in Unity? and if so, what am i doing wrong?
Any help is very much appreciated.
Answer by tmalhassan · Mar 06, 2019 at 02:17 PM
Hello @Geads. Yes I managed to solve the issue and successfully send the request and get the response. There is an asset on the Assets store that shows you how to do it in details. From that code and the Twitter API docs, you can figure out all that you need to do... here’s the link to the asset.
Please support the owner of the asset as well, all credits go to them. And do let me know if you need further help.
Thank you for your help! I was able to authenticate correctly, but I'm having trouble figuring out how to do GET and POST requests from the API. Can we private message on here somehow?
Or if you could just post the code you used to complete your get request of
"https://api.twitter.com/1.1/users/show.json?screen_name=userName"
I should be able to figure it out from there.
@Geads did you download the asset? It literally has the entire code from A-Z
It has the code to log in and post a tweet, I did not see anything for GET requests to make your own api calls. $$anonymous$$aybe we have a different version. I tried to change it to fit what I need and I get error code 32
Your answer
Follow this Question
Related Questions
Unity and TweetSharp / Twitter 2 Answers
Authenticate steam user ID to avoid "fraud" 1 Answer
How to implement authorization URL opening in browser to get auth code? 0 Answers
Upload photo to Twitter 0 Answers
MYSQL for webplayer 0 Answers