public IEnumerator SendData(string logString, string stackTrace, string type) { TwitterAuthenticator Authenticator = null; TwitterInteractor Interactor = null; if (Authenticator == null) { Authenticator = TwitterAuthenticator.Instance; } Debug.Log("have authenticator."); // See if the accesstoken and access secret have already been entered before string accesstoken = PlayerPrefs.GetString("Access Token"); string accessSecret = PlayerPrefs.GetString("Access Secret"); // If the access token and access secret have been set before, then load them back into the API if (!string.IsNullOrEmpty(accesstoken) && !string.IsNullOrEmpty(accessSecret)) { // Set the tokens to the previously received tokens Authenticator.setTokens(accesstoken, accessSecret); Interactor = new TwitterInteractor(Authenticator); } Debug.Log("Logging to google forms."); WebClient client = new WebClient(); var keyValue = new NameValueCollection(); keyValue.Add("entry.1996553891", Interactor.getLoggedInUserScreenName()); // twitter screename keyValue.Add("entry.4768965464", Interactor.getCurrentUser()); // full name keyValue.Add("entry.1696860947", stackTrace); // stack trace keyValue.Add("entry.441305901", logString); // error condition keyValue.Add("entry.174248846", DateTime.Now.ToString()); // error date and tiem keyValue.Add("entry.736989736", type.ToString()); // error type Uri uri = new Uri("https://docs.google.com/forms/d/e/1FAIpQLSfhhipZz7EgdRDacPna2m-gOnV97phLahegPhWcmJdRgD2SEA/formResponse"); byte[] response = client.UploadValues(uri, "POST", keyValue); yield return(Encoding.UTF8.GetString(response)); }
// This is the on click event for when the user enters their pin code that they received from the twitter website. public void onPinEnter() { string pinCode = userInput.text; // make sure the user has entered a pin code if (string.IsNullOrEmpty(pinCode)) { DisplayManager.PushNotification("Please input a value for the pin code!"); return; } if (makeTwitterAPICall(() => Authenticator.enterPinCode(pinCode))) { string accessToken = Authenticator.getAccessToken(); string accessSecret = Authenticator.getAccessTokenSecret(); // Save the access token so they do not have to authenticate themselves again. PlayerPrefs.SetString("Access Token", accessToken); PlayerPrefs.SetString("Access Secret", accessSecret); if (Interactor == null) { Interactor = new TwitterInteractor(Authenticator); } if (Interactor == null) { DisplayManager.PushNotification("Something went wrong with your twitter authentication. If this persists please contact the development team."); navigateToTwitterAuthPage("Interactor is null"); } navigateToTwitterHome(); } else { DisplayManager.PushNotification("Please input a value for the pin code!"); } }
public void initializeAuthComponent() { if (Authenticator == null) { try { Authenticator = TwitterAuthenticator.Instance; } catch (Exception e) { Debug.Log(e.StackTrace); checkErrorCodes(e); } } if (Authenticator == null) { DisplayManager.PushNotification("Something went wrong with your twitter authentication. If this persists please contact the development team."); navigateToTwitterAuthPage("Authenticator is null"); } // See if the accesstoken and access secret have already been entered before string accesstoken = PlayerPrefs.GetString("Access Token"); string accessSecret = PlayerPrefs.GetString("Access Secret"); // If the access token and access secret have been set before, then load them back into the API if (Remember && !string.IsNullOrEmpty(accesstoken) && !string.IsNullOrEmpty(accessSecret)) { // Set the tokens to the previously received tokens makeTwitterAPICallNoReturnVal(() => Authenticator.setTokens(accesstoken, accessSecret)); try { Interactor = new TwitterInteractor(Authenticator); } catch (Exception e) { Debug.Log(e.StackTrace); checkErrorCodes(e); } if (Interactor == null) { DisplayManager.PushNotification("Something went wrong with your twitter authentication. If this persists please contact the development team."); navigateToTwitterAuthPage("Interactor is null"); } // Recover from errors having to do with exceptions in home timeline thread Interactor.getHomeTimelineNavigatable().OnExp = exception => { Debug.Log(exception.Message.ToString()); Crashlytics.RecordCustomException("Twitter Exception", "thrown exception", exception.StackTrace); DisplayManager.PushNotification("Something went wrong with your twitter implementation."); navigateToTwitterHome(); }; // Recover from errors having to do with exceptions in dm users thread Interactor.getDmUsersNavigatable().OnExp = exception => { Debug.Log(exception.Message.ToString()); Crashlytics.RecordCustomException("Twitter Exception", "thrown exception", exception.StackTrace); DisplayManager.PushNotification("Something went wrong with your twitter implementation."); navigateToTwitterHome(); }; navigateToTwitterHome(); } else // Otherwise, we need to authenticate the user. { navigateToTwitterAuthPage(); } }