public GetOAuthorization() { InitializeComponent(); account = new Model.AccountTwitter(); requestToken = account.twitterService.GetRequestToken("oob"); string authUrl = account.twitterService.GetAuthorizationUri(requestToken).AbsoluteUri; originalUri = authUrl; webBrowser1.Navigated += new System.Windows.Navigation.NavigatedEventHandler(webBrowser1_Navigated); webBrowser1.Navigate(authUrl); }
public ImageResponse Upload(string Filepath, Model.AccountTwitter account) { return(null); /* hhh * if (File.Exists(Filepath)) * { * // Read file data * FileStream fs = new FileStream(Filepath, FileMode.Open, FileAccess.Read); * byte[] data = new byte[fs.Length]; * fs.Read(data, 0, data.Length); * fs.Close(); * * Twitterizer.WebRequestBuilder oauthRequest = new Twitterizer.WebRequestBuilder(new Uri("https://api.twitter.com/1/account/verify_credentials.xml"), Twitterizer.HTTPVerb.GET, account.Tokens); * oauthRequest.PrepareRequest(); * * // Generate post objects * Dictionary<string, object> postParameters = new Dictionary<string, object>(); * Dictionary<string, string> additonalHeaders = new Dictionary<string, string>(); * string CredentialAuthorization = oauthRequest.GenerateAuthorizationHeader(); * * additonalHeaders.Add("X-Verify-Credentials-Authorization", CredentialAuthorization); * additonalHeaders.Add("X-Auth-Service-Provider", "https://api.twitter.com/1/account/verify_credentials.xml"); * * postParameters.Add("api_key", apiKey); * postParameters.Add("response_format", "json"); * postParameters.Add("isoauth", "true"); * postParameters.Add("media ", data); * * // Create request and receive response * string postURL = "http://tweetphotoapi.com/api/upload.aspx"; * HttpWebResponse webResponse = WebHelpers.MultipartFormDataPost(postURL, postParameters, account, additonalHeaders); * * StreamReader responseReader = new StreamReader(webResponse.GetResponseStream()); * string fullResponse = responseReader.ReadToEnd(); * webResponse.Close(); * return parseResponse(fullResponse); * } * else * { * return null; * } * */ }
void authWindow_AuthSuccess(object sender, GetOAuthorization.AuthSuccessEventArgs e) { GetOAuthorization authWindow = sender as GetOAuthorization; AppController.Current.sendNotification("General info", "Authorization in progress", "", "", null); AppController.Current.Logger.addDebugMessage("Start Twitter auth", ""); AppController.Current.Logger.addDebugMessage("Proxy enabled", Properties.Settings.Default.ProxyEnabled.ToString(), type: DebugMessage.DebugMessageTypes.LogMessage); AppController.Current.Logger.addDebugMessage("Proxy server", Properties.Settings.Default.ProxyServer, type: DebugMessage.DebugMessageTypes.LogMessage); AppController.Current.Logger.addDebugMessage("Proxy port", Properties.Settings.Default.ProxyPort.ToString(), type: DebugMessage.DebugMessageTypes.LogMessage); OAuthAccessToken accessToken = null; try { accessToken = authWindow.account.twitterService.GetAccessToken(e.requestToken, e.verifyKey); } catch (Exception exp) { AppController.Current.Logger.addDebugMessage(exp.Message, exp.StackTrace, type: DebugMessage.DebugMessageTypes.Twitter); AppController.Current.sendNotification("Error", exp.Message, exp.StackTrace, "", null); } try { authWindow.account.Token = accessToken.Token; authWindow.account.TokenSecret = accessToken.TokenSecret; authWindow.account.verifyCredentials(); Model.AccountTwitter newAccount = authWindow.account; newAccount.IsStreamingAccount = true; newAccount.getLists(); newAccount.getSearches(); newAccount.UpdateItems(); AppController.Current.Logger.addDebugMessage("New Twitter account authoried", "", account: newAccount, type: DebugMessage.DebugMessageTypes.FirstStartWizard); AppController.Current.AllAccounts.Add(newAccount); } catch (Exception exp) { AppController.Current.Logger.addDebugMessage(exp.Message, exp.StackTrace, type: DebugMessage.DebugMessageTypes.Twitter); AppController.Current.sendNotification("Error", exp.Message, exp.StackTrace, "", null); } }
void authWindow_AuthSuccess(object sender, GetOAuthorization.AuthSuccessEventArgs e) { AppController.Current.sendNotification("General info", "Authorization in progress", "", "", null); GetOAuthorization authWindow = sender as GetOAuthorization; OAuthAccessToken accessToken = null; try { accessToken = authWindow.account.twitterService.GetAccessToken(e.requestToken, e.verifyKey); } catch (Exception exp) { AppController.Current.sendNotification("Error", exp.Message, exp.StackTrace, "", null); } try { authWindow.account.Token = accessToken.Token; authWindow.account.TokenSecret = accessToken.TokenSecret; authWindow.account.verifyCredentials(); Model.AccountTwitter newAccount = authWindow.account; newAccount.IsStreamingAccount = true; newAccount.getLists(); newAccount.getSearches(); newAccount.UpdateItems(); AppController.Current.AllAccounts.Add(newAccount); AppController.Current.saveAccountsAndViews(); if (AppController.Current.AllViews.Count == 0) { tabViews.IsSelected = true; buttonViewAdd_Click(null, null); } } catch (Exception exp) { AppController.Current.sendNotification("Error", exp.Message, exp.StackTrace, "", null); } }
public ImageResponse Upload(string Filepath, string Description, Model.AccountTwitter account) { return(Upload(Filepath, account)); }
public ImageResponse Upload(string Filepath, Model.AccountTwitter account) { throw new NotImplementedException(); }