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.