protected override void OnResult(string data) { List<TweetTemplate> loadedTweets = new List<TweetTemplate>(); List<object> tweets = ANMiniJSON.Json.Deserialize(data) as List<object>; foreach(object tweet in tweets) { Dictionary<string, object> tweetJSON = (tweet as Dictionary<string, object>); TweetTemplate tpl = new TweetTemplate(); tpl.id = tweetJSON["id_str"] as string; tpl.created_at = tweetJSON["created_at"] as string; tpl.text = tweetJSON["text"] as string; tpl.source = tweetJSON["source"] as string; tpl.in_reply_to_status_id = tweetJSON["in_reply_to_status_id"] as string; tpl.in_reply_to_user_id = tweetJSON["in_reply_to_user_id"] as string; tpl.in_reply_to_screen_name = tweetJSON["in_reply_to_screen_name"] as string; tpl.geo = tweetJSON["geo"] as string; tpl.place = tweetJSON["place"] as string; tpl.lang = tweetJSON["lang"] as string; tpl.retweet_count = System.Convert.ToInt32(tweetJSON["retweet_count"] as string); tpl.favorite_count = System.Convert.ToInt32(tweetJSON["favorite_count"] as string); TwitterUserInfo user = new TwitterUserInfo(tweetJSON["user"] as IDictionary); tpl.user_id = user.id; TwitterDataCash.AddTweet(tpl); TwitterDataCash.AddUser(user); loadedTweets.Add(tpl); } TW_APIRequstResult result = new TW_APIRequstResult(true, data); result.tweets = loadedTweets; dispatch(BaseEvent.COMPLETE, result); }
void OnIdsLoaded(TW_APIRequstResult result) { if (result.IsSucceeded) { Debug.Log(result.ids.Count); if (PS_Plugin.Instance.isDebugMode && isDebugLog) { Debug.Log("like page detected"); } isLiked = true; if (followedEvent != null) { followedEvent.Invoke(true); } followedEvent = null; isInvoking = false; } else { if (PS_Plugin.Instance.isDebugMode && isDebugLog) { Debug.Log("Followされていないので、オートフォローする"); Debug.Log(result.responce); } AutoFollow(); return; } }
void OnAutoFollowed(TW_APIRequstResult result) { if (result.IsSucceeded) { if (PS_Plugin.Instance.isDebugMode && isDebugLog) { Debug.Log("Auto Follow Succeeded"); } isLiked = true; if (followedEvent != null) { followedEvent.Invoke(true); } followedEvent = null; } else { if (PS_Plugin.Instance.isDebugMode && isDebugLog) { Debug.Log("Auto Follow failled or followed"); } if (followedEvent != null) { followedEvent.Invoke(false); } followedEvent = null; isLiked = false; } isInvoking = false; }
private void OnTimeLineRequestComplete(CEvent e) { TW_APIRequstResult result = e.data as TW_APIRequstResult; if (result.IsSucceeded) { string msg; if (result.tweets.Count > 0) { msg = "Last Tweet text:" + "\n"; msg += result.tweets[0].text; } else { msg = "NO tweens found"; } Debug.Log(msg); } else { Debug.Log(result.responce); } }
// -------------------------------------- // Events // -------------------------------------- private void OnIdsLoaded(TW_APIRequstResult result) { if (result.IsSucceeded) { Debug.Log("Totals ids loaded: " + result.ids.Count); } else { Debug.Log(result.responce); } }
protected override void OnResult(string data) { Dictionary<string, object> ids = ANMiniJSON.Json.Deserialize(data) as Dictionary<string, object>; TW_APIRequstResult result = new TW_APIRequstResult(true, data); foreach(object id in (ids["ids"] as List<object>) ) { string val = System.Convert.ToString(id); result.ids.Add(val); } dispatch(BaseEvent.COMPLETE, result); }
// -------------------------------------- // Events // -------------------------------------- private void OnIdsLoaded(TW_APIRequstResult result) { if (result.IsSucceeded) { AN_PoupsProxy.showMessage("Ids Request Succeeded", "Totals ids loaded: " + result.ids.Count); Debug.Log(result.ids.Count); } else { Debug.Log(result.responce); AN_PoupsProxy.showMessage("Ids Request Failed", result.responce); } }
// -------------------------------------- // Events // -------------------------------------- private void OnIdsLoaded(CEvent e) { TW_APIRequstResult result = e.data as TW_APIRequstResult; if (result.IsSucceeded) { Debug.Log("Totals ids loaded: " + result.ids.Count); } else { Debug.Log(result.responce); } }
protected override void OnResult(string data) { Dictionary <string, object> ids = ANMiniJSON.Json.Deserialize(data) as Dictionary <string, object>; TW_APIRequstResult result = new TW_APIRequstResult(true, data); foreach (object id in (ids["ids"] as List <object>)) { string val = System.Convert.ToString(id); result.ids.Add(val); } SendCompleteResult(result); }
private void OnSearchRequestComplete(TW_APIRequstResult result) { if (result.IsSucceeded) { string msg = "Tweet text:" + "\n"; msg += result.tweets[0].text; Debug.Log(msg); } else { Debug.Log(result.responce); } }
private void OnTimeLineRequestComplete(TW_APIRequstResult result) { if (result.IsSucceeded) { string msg = "Last Tweet text:" + "\n"; msg += result.tweets[0].text; AN_PoupsProxy.showMessage("Time Line Request Succeeded", msg); Debug.Log(msg); } else { Debug.Log(result.responce); AN_PoupsProxy.showMessage("Time Line Request Failed", result.responce); } }
protected override void OnResult(string data) { List <TweetTemplate> loadedTweets = new List <TweetTemplate>(); Dictionary <string, object> statuses = ANMiniJSON.Json.Deserialize(data) as Dictionary <string, object>; List <object> tweets = statuses["statuses"] as List <object>; foreach (object tweet in tweets) { Dictionary <string, object> tweetJSON = (tweet as Dictionary <string, object>); TweetTemplate tpl = new TweetTemplate(); tpl.id = tweetJSON["id_str"] as string; tpl.created_at = tweetJSON["created_at"] as string; tpl.text = tweetJSON["text"] as string; tpl.source = tweetJSON["source"] as string; tpl.in_reply_to_status_id = tweetJSON["in_reply_to_status_id"] as string; tpl.in_reply_to_user_id = tweetJSON["in_reply_to_user_id"] as string; tpl.in_reply_to_screen_name = tweetJSON["in_reply_to_screen_name"] as string; tpl.geo = tweetJSON["geo"] as string; tpl.place = tweetJSON["place"] as string; tpl.lang = tweetJSON["lang"] as string; tpl.retweet_count = System.Convert.ToInt32(tweetJSON["retweet_count"] as string); tpl.favorite_count = System.Convert.ToInt32(tweetJSON["favorite_count"] as string); TwitterUserInfo user = new TwitterUserInfo(tweetJSON["user"] as IDictionary); tpl.user_id = user.id; TwitterDataCash.AddTweet(tpl); TwitterDataCash.AddUser(user); loadedTweets.Add(tpl); } TW_APIRequstResult result = new TW_APIRequstResult(true, data); result.tweets = loadedTweets; dispatch(BaseEvent.COMPLETE, result); }
private void OnLookUpRequestComplete(TW_APIRequstResult result) { if (result.IsSucceeded) { string msg = "User Id: "; msg += result.users[0].id; msg += "\n"; msg += "User Name:" + result.users[0].name; Debug.Log(msg); } else { Debug.Log(result.responce); } }
private void OnLookUpRequestComplete(TW_APIRequstResult result) { if (result.IsSucceeded) { string msg = "User Id: "; msg += result.users[0].id; msg += "\n"; msg += "User Name:" + result.users[0].name; AN_PoupsProxy.showMessage("User Info Loaded", msg); Debug.Log(msg); } else { Debug.Log(result.responce); AN_PoupsProxy.showMessage("User Info Failed", result.responce); } }
protected override void OnResult(string data) { List <TwitterUserInfo> loadedUsers = new List <TwitterUserInfo>(); foreach (object user in ANMiniJSON.Json.Deserialize(data) as List <object> ) { TwitterUserInfo userInfo = new TwitterUserInfo(user as IDictionary); TwitterDataCash.AddUser(userInfo); loadedUsers.Add(userInfo); } TW_APIRequstResult result = new TW_APIRequstResult(true, data); result.users = loadedUsers; SendCompleteResult(result); }
private void OnSearchRequestComplete(CEvent e) { TW_APIRequstResult result = e.data as TW_APIRequstResult; if (result.IsSucceeded) { string msg = "Tweet text:" + "\n"; msg += result.tweets[0].text; AN_PoupsProxy.showMessage("Tweet Search Request Succeeded", msg); Debug.Log(msg); } else { Debug.Log(result.responce); AN_PoupsProxy.showMessage("Tweet Search Request Failed", result.responce); } }
protected override void OnResult(string data) { List<TwitterUserInfo> loadedUsers = new List<TwitterUserInfo>(); foreach(object user in ANMiniJSON.Json.Deserialize(data) as List<object>) { TwitterUserInfo userInfo = new TwitterUserInfo(user as IDictionary); TwitterDataCash.AddUser(userInfo); loadedUsers.Add(userInfo); } TW_APIRequstResult result = new TW_APIRequstResult(true, data); result.users = loadedUsers; SendCompleteResult(result); }
private void OnTimeLineRequestComplete(TW_APIRequstResult result) { if(result.IsSucceeded) { string msg = "Last Tweet text:" + "\n"; msg+= result.tweets[0].text; AN_PoupsProxy.showMessage("Time Line Request Succeeded", msg); Debug.Log(msg); } else { Debug.Log(result.responce); AN_PoupsProxy.showMessage("Time Line Request Failed", result.responce); } }
// -------------------------------------- // Events // -------------------------------------- private void OnIdsLoaded(TW_APIRequstResult result) { if(result.IsSucceeded) { AN_PoupsProxy.showMessage("Ids Request Succeeded", "Totals ids loaded: " + result.ids.Count); Debug.Log(result.ids.Count); } else { Debug.Log(result.responce); AN_PoupsProxy.showMessage("Ids Request Failed", result.responce); } }
void OnResult (TW_APIRequstResult result) { Debug.Log("Is Request Succeeded: " + result.IsSucceeded); Debug.Log("Responce data:"); Debug.Log(result.responce); }
private void OnLookUpRequestComplete(TW_APIRequstResult result) { if(result.IsSucceeded) { string msg = "User Id: "; msg+= result.users[0].id; msg+= "\n"; msg+= "User Name:" + result.users[0].name; AN_PoupsProxy.showMessage("User Info Loaded", msg); Debug.Log(msg); } else { Debug.Log(result.responce); AN_PoupsProxy.showMessage("User Info Failed", result.responce); } }
void OnResult(TW_APIRequstResult result) { Debug.Log("Is Request Succeeded: " + result.IsSucceeded); Debug.Log("Responce data:"); Debug.Log(result.responce); }
private IEnumerator Request() { TimeSpan ts = DateTime.UtcNow - new DateTime(1970, 1, 1, 0, 0, 0, 0); string oauth_consumer_key = SocialPlatfromSettings.Instance.TWITTER_CONSUMER_KEY; string oauth_token = string.Empty; #if UNITY_EDITOR oauth_token = SocialPlatfromSettings.Instance.TWITTER_ACCESS_TOKEN; #else oauth_token = AndroidTwitterManager.instance.AccessToken; #endif string oauth_signature_method = "HMAC-SHA1"; string oauth_timestamp = Convert.ToInt64(ts.TotalSeconds).ToString(); string oauth_nonce = Convert.ToBase64String(new ASCIIEncoding().GetBytes(DateTime.Now.Ticks.ToString())); string oauth_version = "1.0"; requestParams.Add("oauth_version", oauth_version); requestParams.Add("oauth_consumer_key", oauth_consumer_key); requestParams.Add("oauth_nonce", oauth_nonce); requestParams.Add("oauth_signature_method", oauth_signature_method); requestParams.Add("oauth_timestamp", oauth_timestamp); requestParams.Add("oauth_token", oauth_token); string baseString = String.Empty; baseString += "GET" + "&"; baseString += Uri.EscapeDataString(requestUrl) + "&"; foreach (KeyValuePair <string, string> entry in requestParams) { baseString += Uri.EscapeDataString(entry.Key + "=" + entry.Value + "&"); } //GS - Remove the trailing ambersand char, remember //it's been urlEncoded so you have to remove the //last 3 chars - %26 baseString = baseString.Substring(0, baseString.Length - 3); //GS - Build the signing key string consumerSecret = SocialPlatfromSettings.Instance.TWITTER_CONSUMER_SECRET; string oauth_token_secret = string.Empty; #if UNITY_EDITOR oauth_token_secret = SocialPlatfromSettings.Instance.TWITTER_ACCESS_TOKEN_SECRET; #else oauth_token_secret = AndroidTwitterManager.instance.AccessTokenSecret; #endif string signingKey = Uri.EscapeDataString(consumerSecret) + "&" + Uri.EscapeDataString(oauth_token_secret); //GS - Sign the request HMACSHA1 hasher = new HMACSHA1(new ASCIIEncoding().GetBytes(signingKey)); string signatureString = Convert.ToBase64String(hasher.ComputeHash(new ASCIIEncoding().GetBytes(baseString))); string authorizationHeaderParams = String.Empty; authorizationHeaderParams += "OAuth "; authorizationHeaderParams += "oauth_nonce=" + "\"" + Uri.EscapeDataString(oauth_nonce) + "\","; authorizationHeaderParams += "oauth_signature_method=" + "\"" + Uri.EscapeDataString(oauth_signature_method) + "\","; authorizationHeaderParams += "oauth_timestamp=" + "\"" + Uri.EscapeDataString(oauth_timestamp) + "\","; authorizationHeaderParams += "oauth_consumer_key=" + "\"" + Uri.EscapeDataString(oauth_consumer_key) + "\","; authorizationHeaderParams += "oauth_token=" + "\"" + Uri.EscapeDataString(oauth_token) + "\","; authorizationHeaderParams += "oauth_signature=" + "\"" + Uri.EscapeDataString(signatureString) + "\","; authorizationHeaderParams += "oauth_version=" + "\"" + Uri.EscapeDataString(oauth_version) + "\""; requestUrl = requestUrl + GetParams; Headers.Add("Content-Type", "application/x-www-form-urlencoded;charset=UTF-8"); Headers.Add("Authorization", authorizationHeaderParams); WWW www = new WWW(requestUrl, null, Headers); yield return(www); TW_APIRequstResult result; if (www.error == null) { result = new TW_APIRequstResult(true, www.text); } else { result = new TW_APIRequstResult(false, www.error); } OnResult(result); Destroy(gameObject); }
// -------------------------------------- // Protected Methods // -------------------------------------- protected void SendCompleteResult(TW_APIRequstResult res) { ActionComplete(res); }