public void GetProfile() { if (!string.IsNullOrEmpty(AccessToken)) { user = Twitter.API.GetProfileInfo(usernameInput.text, AccessToken, false); if (user != null) { Texture2D ava = Twitter.helperFunctions.GetTextureFromImageURL(user.profile_image_url); UserAvatar.sprite = Sprite.Create( ava, new Rect(0, 0, ava.width, ava.height), Vector2.one / 2 ); } else { Debug.Log("User not found"); } } else { Debug.Log("No access token :("); } }
private void LoadTwitterContent(string twitterHandle) { accessToken = Twitter.API.GetTwitterAccessToken(twitterKeyChris, secretChris); Debug.Log(accessToken); if (accessToken != null) { newUser = Twitter.API.GetProfileInfo(twitterHandle, accessToken, false); tweets = Twitter.API.GetUserTimeline(twitterHandle, 5, accessToken); if (newUser == null || tweets == null) { Debug.Log("User or Tweets is null"); return; } twitterIndex = 0; Debug.Log("twitter image url: " + newUser.profile_image_url); StartCoroutine(DownloadTwitterImage(newUser.profile_image_url)); InvokeRepeating("DisplayTweet", 0f, 5f); } else { Debug.Log("Access Token is NULL!"); } }
void Start() { accessToken = Twitter.API.GetTwitterAccessToken(key, secret); Debug.Log(accessToken); if (accessToken != null) { newUser = Twitter.API.GetProfileInfo("BBC", accessToken, false); tweets = Twitter.API.GetUserTimeline("BBC", 6, accessToken); if (newUser == null || tweets == null) { Debug.Log("User or Tweets is null"); return; } for (int i = 0; i < 1; i++) { Debug.Log("Generating new Dialog game object"); Dialog dialog = Dialog.Open(dialogPrefab.gameObject, DialogButtonType.Next | DialogButtonType.Close, tweets[i].user.screen_name, tweets[i].text); } } else { Debug.Log("Access Token is NULL!"); } }
private void Start() { accesstoken = Twitter.API.GetTwitterAccessToken(key, secret); newUser = Twitter.API.GetProfileInfo("@infocianjur", accesstoken, false); tweets = Twitter.API.GetUserTimeline("@infocianjur", 5, accesstoken); updateData(Texture2D); }
public bool authenticateUser(string userAccessToken, string userAccessTokenSecret) { if (this.userCredentials == null) { var userCredentials = new TwitterCredentials(this.ConsumerKey, this.ConsumerSecret, userAccessToken, userAccessTokenSecret); this.User = Tweetinvi.User.GetAuthenticatedUser(userCredentials); if(this.user != null) { storeUserCredentials(userCredentials.AccessToken, userCredentials.AccessTokenSecret); this.twitterUser = new TwitterUser(this.user); return true; } } else throw new Exception("User credensials cannot be null"); return false; }
public static TwitterUser GetProfileInfo(string name, string AccessToken, bool isID) { string s = WebRequest("https://api.twitter.com/1.1/users/show.json?" + (isID ? "user_id=" : "screen_name=") + name + "&include_entities=false", AccessToken); TwitterUser output = JsonUtility.FromJson <TwitterUser>(s); if (output != null) { output.FormatCreationTime(); //if (output.status.created_at != null) { // output.status.FormatCreationTime(); //if (output.status.retweeted_status.created_at != null) // output.status.retweeted_status.FormatCreationTime(); //} if (output.screen_name == " ") { output.screen_name = "Somebody with a non-ascii name"; } Debug.Log(output.screen_name + " profile retrieved"); return(output); } return(null); }
private void Start() { accesstoken = Twitter.API.GetTwitterAccessToken(key, secret); newUser = Twitter.API.GetProfileInfo("TwitterDev", accesstoken, false); tweets = Twitter.API.GetUserTimeline("TwitterDev", 5, accesstoken); }
public static void GetProfile(string userID, bool isID, string AccessToken, twitterButton caller, bool zombie) { Dictionary<string, string> headers = new Dictionary<string, string>(); headers["Authorization"] = "Bearer " + AccessToken; string url = "https://api.twitter.com/1.1/users/show.json"; if (isID) { url += "?user_id="; } else { url += "?screen_name="; } WWW web = new WWW(url + userID, null, headers); while (!web.isDone) { Debug.Log("Grabbing profile info..."); } Debug.Log(userID); Debug.Log("web: " + "\n" + web.text); Debug.Log("Extracting profile data..."); List<string> avatarURL = extractData(web.text, ",\"profile_image_url\":\"", "\",\"profile_image_url_https\":"); avatarURL[0] = avatarURL[0].Remove(avatarURL[0].IndexOf("_normal"), 7); List<string> text = extractData(web.text, ",\"text\":\"", ",\"source\":"); int a = web.text.IndexOf("\"status\"", 0); int b = web.text.IndexOf("\"contributors_enabled\"", 0); int length = b - a; string newText = web.text; if (a != -1 && b != -1) { newText = web.text.Remove(a, length); Debug.Log(newText); } int c = web.text.IndexOf(",\"profile_location\":", 0); int d = web.text.IndexOf(",\"description\":", 0); int lengthROUNDTWO = d - c; if (c != -1 && d != -1) { Debug.Log(c + " " + d); newText = newText.Remove(c + 22, lengthROUNDTWO - 22); } List<string> anID = extractData(newText, "{\"id\":", ",\"id_str\":"); List<string> displayName = extractData(newText, ",\"name\":\"", "\",\"screen_name\":"); List<string> username = extractData(newText, ",\"screen_name\":\"", "\",\"location\":"); List<string> location = extractData(newText, ",\"location\":\"", "\",\"profile_location\":"); List<string> bio = extractData(newText, ",\"description\":\"", "\",\"url\":"); List<string> website = extractData(newText, ",\"display_url\":\"", "\",\"indices\":"); List<string> joinDate = extractData(newText, ",\"created_at\":\"", "\",\"favourites_count\":"); List<string> verified = extractData(newText, ",\"verified\":", ",\"statuses_count\":"); List<string> totalTweets = extractData(newText, ",\"statuses_count\":", ",\"lang\":"); List<string> followers = extractData(newText, ",\"followers_count\":", ",\"friends_count\":"); TwitterUser user = new TwitterUser(); user.ID = anID[0]; user.displayName = displayName[0]; user.avatarURL = avatarURL[0]; user.username = username[0]; if (text.Count > 0) user.mostRecentTweet = text[0]; user.location = location[0]; user.bio = bio[0]; if (website.Count > 0) user.websiteURL = website[0]; else user.websiteURL = null; user.joinDate = joinDate[0]; user.verified = Convert.ToBoolean(verified[0]); user.followers = int.Parse(followers[0]); user.totalTweets = int.Parse(totalTweets[0]); if (!zombie) caller.templeHead(avatarURL[0],user); else caller.MakeZombie(user); }
//Will run in GUI, waits for input. public void authenticateUser(string pin) { // With this pin code it is now possible to get the credentials back from Twitter this.userCredentials = AuthFlow.CreateCredentialsFromVerifierCode(pin, authenticationContext); // Use the user credentials in your application Auth.SetCredentials(this.userCredentials); // Get the AuthenticatedUser from the current thread credentials this.User = Tweetinvi.User.GetAuthenticatedUser(); // Stores the usercredentials for later use this.storeUserCredentials(this.userCredentials.AccessToken, this.userCredentials.AccessTokenSecret); this.twitterUser = new TwitterUser(this.user); }