public TwitPicUploader(string key, OAuthInfo oauth) { APIKey = key; AuthInfo = oauth; TwitPicUploadType = TwitPicUploadType.UPLOAD_IMAGE_ONLY; ShowFull = false; TwitPicThumbnailMode = TwitPicThumbnailType.Thumb; }
private AccountInfo GetAccountInfo(OAuthInfo oauth) { var uri = new Uri("https://api.dropbox.com/1/account/info"); var client = GetDropboxClient(HttpMethod.Get, uri, oauth); var response = client.GetAsync(uri.PathAndQuery).Result.EnsureSuccessful(); using (var reader = new JsonTextReader(new StreamReader(response.Content.ReadAsStreamAsync().Result))) { JsonSerializer serializer = new JsonSerializer(); return serializer.Deserialize<AccountInfo>(reader); } }
public void Tweet(string text) { string[] creds = File.ReadAllLines("./config.cfg"); OAuthInfo TInfo = new OAuthInfo(); TInfo.ConsumerKey = creds[0]; TInfo.ConsumerSecret = creds[1]; TInfo.AccessToken = creds[2]; TInfo.AccessSecret = creds[3]; TinyTwitter.TinyTwitter Manager = new TinyTwitter.TinyTwitter(TInfo); Manager.UpdateStatus(text.Replace("\n\n","")); }
/// <summary> /// 创建开放授权用户 /// </summary> /// <param name="oUserName">开放用户名</param> /// <param name="uNamePrefix">用户名前缀</param> /// <param name="openId">开放id</param> /// <param name="server">服务商</param> /// <param name="regionId">区域id</param> /// <returns></returns> public static UserInfo CreateOAuthUser(string oUserName, string uNamePrefix, string openId, string server, int regionId) { UserInfo userInfo = InitUser(oUserName, uNamePrefix, regionId); int uid = Users.CreateUser(userInfo); if (uid > 0) { userInfo.Uid = uid; OAuthInfo oauthInfo = new OAuthInfo() { Uid = uid, OpenId = openId, Server = server }; BrnShop.Data.OAuths.CreateOAuthUser(oauthInfo); } else { userInfo = null; } return(userInfo); }
/// <summary> /// 数据转第三方登录实体 /// </summary> public static OAuthInfo DataToModel(SqlDataReader rdr) { OAuthInfo oauth = new OAuthInfo(); if (!rdr.IsDBNull(0)) { oauth.OAuthID = rdr.GetInt32(0); } if (!rdr.IsDBNull(1)) { oauth.OpenID = rdr.GetString(1); } if (!rdr.IsDBNull(2)) { oauth.AccessToken = rdr.GetString(2); } if (!rdr.IsDBNull(3)) { oauth.UserID = rdr.GetInt32(3); } if (!rdr.IsDBNull(4)) { oauth.OldUserID = rdr.GetInt32(4); } if (!rdr.IsDBNull(5)) { oauth.OAuthBound = rdr.GetByte(5); } if (!rdr.IsDBNull(6)) { oauth.OAuthFrom = rdr.GetString(6); } if (!rdr.IsDBNull(7)) { oauth.ModifyDate = rdr.GetDateTime(7); } return(oauth); }
private DeltaInfo GetDeltaInfo(OAuthInfo oauth, string cursor = null) { Uri uri; HttpClient client; if (!String.IsNullOrEmpty(cursor)) { uri = new Uri("https://api.dropbox.com/1/delta/?cursor=" + cursor); client = GetDropboxClient(HttpMethod.Post, uri, oauth, new KeyValuePair<string, string>("cursor", cursor)); } else { uri = new Uri("https://api.dropbox.com/1/delta"); client = GetDropboxClient(HttpMethod.Post, uri, oauth); } var response = client.PostAsync(uri.PathAndQuery, null).Result.EnsureSuccessful(); using (var reader = new JsonTextReader(new StreamReader(response.Content.ReadAsStreamAsync().Result))) { JsonSerializer serializer = new JsonSerializer(); return new DeltaInfo(serializer.Deserialize<JObject>(reader)); } }
// https://www.dropbox.com/developers/core/api#fileops-delete public DropboxContentInfo Delete(string path) { DropboxContentInfo contentInfo = null; if (!string.IsNullOrEmpty(path) && OAuthInfo.CheckOAuth(AuthInfo)) { Dictionary <string, string> args = new Dictionary <string, string>(); args.Add("root", Root); args.Add("path", path); string query = OAuthManager.GenerateQuery(URLDelete, args, HttpMethod.Post, AuthInfo); string response = SendPostRequest(query); if (!string.IsNullOrEmpty(response)) { contentInfo = JsonConvert.DeserializeObject <DropboxContentInfo>(response); } } return(contentInfo); }
public static void TweetMessage() { TaskEx.Run(() => { OAuthInfo twitterOAuth = Program.UploadersConfig.TwitterOAuthInfoList.ReturnIfValidIndex(Program.UploadersConfig.TwitterSelectedAccount); if (twitterOAuth != null) { using (TwitterTweetForm twitter = new TwitterTweetForm(twitterOAuth)) { if (twitter.ShowDialog() == DialogResult.OK && twitter.IsTweetSent) { if (Program.MainForm.niTray.Visible) { Program.MainForm.niTray.Tag = null; Program.MainForm.niTray.ShowBalloonTip(5000, "ShareX - Twitter", Resources.TaskHelpers_TweetMessage_Tweet_successfully_sent_, ToolTipIcon.Info); } } } } }); }
// https://www.dropbox.com/developers/core/api#shares public string CreateShareableLink(string path, DropboxURLType urlType) { if (!string.IsNullOrEmpty(path) && OAuthInfo.CheckOAuth(AuthInfo)) { string url = Helpers.CombineURL(URLShares, Helpers.URLPathEncode(path)); Dictionary <string, string> args = new Dictionary <string, string>(); args.Add("short_url", urlType == DropboxURLType.Shortened ? "true" : "false"); string query = OAuthManager.GenerateQuery(url, args, HttpMethod.POST, AuthInfo); string response = SendRequest(HttpMethod.POST, query); if (!string.IsNullOrEmpty(response)) { DropboxShares shares = JsonConvert.DeserializeObject <DropboxShares>(response); if (urlType == DropboxURLType.Direct) { Match match = Regex.Match(shares.URL, @"https?://(?:www\.)?dropbox.com/s/(?<path>\w+/.+)"); if (match.Success) { string urlPath = match.Groups["path"].Value; if (!string.IsNullOrEmpty(urlPath)) { return(Helpers.CombineURL(URLShareDirect, urlPath)); } } } else { return(shares.URL); } } } return(null); }
public void TestDropboxConcurrent() { OAuthInfo oauth = GetOAuthInfo(); if (oauth == null) { // only run in private kudu return; } AccountInfo account = GetAccountInfo(oauth); DropboxDeployInfo deploy = GetDeployInfo("/BasicTest", oauth, account); string appName = "DropboxTest"; ApplicationManager.Run(appName, appManager => { HttpClient client = HttpClientHelper.CreateClient(appManager.ServiceUrl, appManager.DeploymentManager.Credentials); var tasks = new Task <HttpResponseMessage>[] { client.PostAsJsonAsync("deploy", deploy), client.PostAsJsonAsync("deploy", deploy) }; Task.WaitAll(tasks); var success = tasks[0].Result.IsSuccessStatusCode ? tasks[0].Result : tasks[1].Result; var failure = !Object.ReferenceEquals(success, tasks[0].Result) ? tasks[0].Result : tasks[1].Result; success.EnsureSuccessful(); Assert.Equal(HttpStatusCode.Accepted, failure.StatusCode); var results = appManager.DeploymentManager.GetResultsAsync().Result.ToList(); Assert.Equal(1, results.Count); Assert.Equal(DeployStatus.Success, results[0].Status); Assert.Equal("Dropbox", results[0].Deployer); }); }
// https://www.dropbox.com/developers/core/api#files-POST public UploadResult UploadFile(Stream stream, string path, string fileName, bool createShareableURL = false, DropboxURLType urlType = DropboxURLType.Default) { if (!OAuthInfo.CheckOAuth(AuthInfo)) { Errors.Add("Dropbox login is required."); return(null); } string url = Helpers.CombineURL(URLFiles, Helpers.URLPathEncode(path)); Dictionary <string, string> args = new Dictionary <string, string>(); args.Add("file", fileName); string query = OAuthManager.GenerateQuery(url, args, HttpMethod.POST, AuthInfo); // There's a 150MB limit to all uploads through the API. UploadResult result = UploadData(stream, query, fileName); if (result.IsSuccess) { DropboxContentInfo content = JsonConvert.DeserializeObject <DropboxContentInfo>(result.Response); if (content != null) { if (createShareableURL) { result.URL = CreateShareableLink(content.Path, urlType); } else { result.URL = GetPublicURL(content.Path); } } } return(result); }
protected void Page_Load(object sender, EventArgs e) { userId = Convert.ToInt32(Session["UserID"]); user = bll.GetUserByUserId(userId); //钉钉user dtUser = user.DtUser; //未绑定帐号跳转 OAuthInfo oauth = oauth_bll.GetOAuthByUserId(userId); if (oauth.OAuthID > 0 && oauth.OAuthBound == 0) { Response.Redirect("UserBoundAdmin.aspx"); } if (!IsPostBack) { BindWorkDay(); PopulateControls(); } }
// https://www.dropbox.com/developers/core/api#metadata public DropboxContentInfo GetMetadata(string path, bool list) { DropboxContentInfo contentInfo = null; if (OAuthInfo.CheckOAuth(AuthInfo)) { string url = Helpers.CombineURL(URLMetaData, Helpers.URLPathEncode(path)); Dictionary <string, string> args = new Dictionary <string, string>(); args.Add("list", list ? "true" : "false"); string query = OAuthManager.GenerateQuery(url, args, HttpMethod.GET, AuthInfo); string response = SendRequest(HttpMethod.GET, query); if (!string.IsNullOrEmpty(response)) { contentInfo = JsonConvert.DeserializeObject <DropboxContentInfo>(response); } } return(contentInfo); }
public UserService(OAuthInfo oAuth) { _oAuthInfo = oAuth; var config = new MapperConfiguration(cfg => { cfg.CreateMap <UserDTO, UserModel>(); cfg.CreateMap <UsersDTO, UsersModel>(); cfg.CreateMap <DTO.Users.Data, Models.Users.Data>(); cfg.CreateMap <DTO.Users.Mention, Models.Users.Mention>(); cfg.CreateMap <DTO.Users.Hashtag, Models.Users.Hashtag>(); cfg.CreateMap <DTO.Users.Entities, Models.Users.Entities>(); cfg.CreateMap <DTO.Users.PublicMetrics, Models.Users.PublicMetrics>(); cfg.CreateMap <DTO.Users.Url, Models.Users.Url>(); cfg.CreateMap <DTO.Users.Urls, Models.Users.Urls>(); cfg.CreateMap <DTO.Users.Description, Models.Users.Description>(); cfg.CreateMap <DTO.Users.Includes, Models.Users.Includes>(); cfg.CreateMap <DTO.Users.Tweet, Models.Users.Tweet>(); cfg.CreateMap <DTO.Users.Attachments, Models.Users.Attachments>(); }); _iMapper = config.CreateMapper(); }
// https://www.dropbox.com/developers/core/api#account-info public DropboxAccountInfo GetAccountInfo() { DropboxAccountInfo account = null; if (OAuthInfo.CheckOAuth(AuthInfo)) { string query = OAuthManager.GenerateQuery(URLAccountInfo, null, HttpMethod.Get, AuthInfo); string response = SendGetRequest(query); if (!string.IsNullOrEmpty(response)) { account = JsonConvert.DeserializeObject <DropboxAccountInfo>(response); if (account != null) { AccountInfo = account; } } } return(account); }
// https://developers.copy.com/documentation#api-calls/profile public CopyAccountInfo GetAccountInfo() { CopyAccountInfo account = null; if (OAuthInfo.CheckOAuth(AuthInfo)) { string query = OAuthManager.GenerateQuery(URLAccountInfo, null, HttpMethod.GET, AuthInfo); string response = SendRequest(HttpMethod.GET, query, null, APIHeaders); if (!string.IsNullOrEmpty(response)) { account = JsonConvert.DeserializeObject <CopyAccountInfo>(response); if (account != null) { AccountInfo = account; } } } return(account); }
// https://www.dropbox.com/developers/core/api#shares public DropboxShares CreateShareableLink(string path, bool short_url = true) { DropboxShares shares = null; if (!string.IsNullOrEmpty(path) && OAuthInfo.CheckOAuth(AuthInfo)) { string url = Helpers.CombineURL(URLShares, Helpers.URLPathEncode(path)); Dictionary <string, string> args = new Dictionary <string, string>(); args.Add("short_url", short_url ? "true" : "false"); string query = OAuthManager.GenerateQuery(url, args, HttpMethod.Post, AuthInfo); string response = SendPostRequest(query); if (!string.IsNullOrEmpty(response)) { shares = JsonConvert.DeserializeObject <DropboxShares>(response); } } return(shares); }
public List <TweetInfo> GetHomeTimelineData(string strScreenName, int messageCount = 10) { List <TweetInfo> lstTweetsData = null; try { var oauth = new OAuthInfo { AccessToken = "3243686535-tNfNY6vh6b0KX1b0j4jj1tKNhMhgbbLqbq754JH", AccessSecret = "a9x26TmHthF9hKEnAXBdYGepBRV4S18bnOEuNoQHnvj7Z", ConsumerKey = "73NX1unppnzaD682Swqx82m3r", ConsumerSecret = "HfA0hwbZUZz7WgTPjEjAQUWOpgnnFfGehTL8dIdQyJZaj2zwAj" }; APIInfoProvider objApiInfo = new APIInfoProvider(oauth); lstTweetsData = objApiInfo.GetHomeTimeline(count: messageCount, screenName: strScreenName); } catch (Exception ex) { ex.Message.ToString(); } return(lstTweetsData); }
public TwitterManager(IRepository repo, IConfiguration configuration, ILogger <TwitterManager> logger) { _repository = repo; _configuration = configuration; _logger = logger; string _ConsumerKey = _configuration["AppSettings:ConsumerKey"]; string _ConsumerSecret = _configuration["AppSettings:ConsumerSecret"]; string _AccessToken = _configuration["AppSettings:AccessToken"]; string _AccessTokenSecret = _configuration["AppSettings:AccessTokenSecret"]; OAuthInfo oAuthInfo = new OAuthInfo { AccessSecret = _AccessTokenSecret, AccessToken = _AccessToken, ConsumerSecret = _ConsumerSecret, ConsumerKey = _ConsumerKey }; _twitterStreamService = new SampledStreamService(oAuthInfo); var resourceName = _configuration["AppSettings:EmojiResource"]; LoadEmojiDataFromFileResource(resourceName, _repository); }
/// <summary> /// 第三方登录实体转参数 /// </summary> public static SqlParameter[] ModelToParms(OAuthInfo oauth) { SqlParameter[] parms = { new SqlParameter("@OAuthID", SqlDbType.Int), new SqlParameter("@OpenID", SqlDbType.NVarChar, 100), new SqlParameter("@AccessToken", SqlDbType.NVarChar, 100), new SqlParameter("@UserID", SqlDbType.Int), new SqlParameter("@OldUserID", SqlDbType.Int), new SqlParameter("@OAuthBound", SqlDbType.TinyInt), new SqlParameter("@OAuthFrom", SqlDbType.NVarChar, 10), new SqlParameter("@ModifyDate", SqlDbType.DateTime) }; parms[0].Value = oauth.OAuthID; parms[1].Value = oauth.OpenID; parms[2].Value = oauth.AccessToken; parms[3].Value = oauth.UserID; parms[4].Value = oauth.OldUserID; parms[5].Value = oauth.OAuthBound; parms[6].Value = oauth.OAuthFrom; parms[7].Value = oauth.ModifyDate; return(parms); }
static void Main(string[] args) { //OAuthInfo myOAuth = new OAuthInfo(); //myOAuth.ConsumerKey = ""; //myOAuth.ConsumerSecret = ""; //myOAuth.AccessSecret = ""; //myOAuth.AccessToken = ""; //var myOauth = new //TinyTwitter TT = new TinyTwitter(new OAuthInfo()); //IEnumerable<Tweet> mytimneline = TT.GetHomeTimeline(null, 2); var oauth = new OAuthInfo { AccessToken = "21985278-dud1wSertHCQYTUK5ta5AA0ciqWB31ZsT8Dt8DJg", AccessSecret = "yPDp2TTOOhQj6XDxX7P5TxmNtHZcQ6sJumth8DVzRk", ConsumerKey = "tedRo766zL7mr7TKZkOugA", ConsumerSecret = "WREOp5SZ71EtLCt3T4RboUv1IrkUpPkCpcBxkAGk8" }; var twitter = new TinyTwitter(oauth); //// Update status, i.e, post a new tweet //twitter.UpdateStatus("I'm tweeting from C#"); // Get home timeline tweets var tweets = twitter.GetUserTimeline(null, 5); //twitter.UpdateStatus("First tweet from my program"); // twitter.UpdateStatus("First tweet from my program"); foreach (var tweet in tweets) Console.WriteLine("{0}: {1}: {2}", tweet.UserName, tweet.Text, tweet.Id); Console.ReadKey(); }
public bool IsActive(ImageDestination destination) { switch (destination) { case ImageDestination.ImageShack: return(ImageShackAccountType == AccountType.Anonymous || !string.IsNullOrEmpty(ImageShackRegistrationCode)); case ImageDestination.TinyPic: return(TinyPicAccountType == AccountType.Anonymous || !string.IsNullOrEmpty(TinyPicRegistrationCode)); case ImageDestination.Imgur: return(ImgurAccountType == AccountType.Anonymous || OAuth2Info.CheckOAuth(ImgurOAuth2Info)); case ImageDestination.Flickr: return(!string.IsNullOrEmpty(FlickrAuthInfo.Token)); case ImageDestination.Photobucket: return(PhotobucketAccountInfo != null && OAuthInfo.CheckOAuth(PhotobucketOAuthInfo)); case ImageDestination.Picasa: return(OAuth2Info.CheckOAuth(PicasaOAuth2Info)); case ImageDestination.Twitpic: case ImageDestination.Twitsnaps: return(TwitterOAuthInfoList != null && TwitterOAuthInfoList.IsValidIndex(TwitterSelectedAccount)); case ImageDestination.yFrog: return(!string.IsNullOrEmpty(YFrogUsername) && !string.IsNullOrEmpty(YFrogPassword)); case ImageDestination.CustomImageUploader: return(CustomUploadersList != null && CustomUploadersList.IsValidIndex(CustomImageUploaderSelected)); default: return(true); } }
private DeltaInfo GetDeltaInfo(OAuthInfo oauth, string cursor = null) { Uri uri; HttpClient client; if (!String.IsNullOrEmpty(cursor)) { uri = new Uri("https://api.dropbox.com/1/delta/?cursor=" + cursor); client = GetDropboxClient(HttpMethod.Post, uri, oauth, new KeyValuePair <string, string>("cursor", cursor)); } else { uri = new Uri("https://api.dropbox.com/1/delta"); client = GetDropboxClient(HttpMethod.Post, uri, oauth); } var response = client.PostAsync(uri.PathAndQuery, null).Result.EnsureSuccessful(); using (var reader = new JsonTextReader(new StreamReader(response.Content.ReadAsStreamAsync().Result))) { JsonSerializer serializer = new JsonSerializer(); return(new DeltaInfo(serializer.Deserialize <JObject>(reader))); } }
public TwitterTweetForm(OAuthInfo oauth, string message) : this(oauth) { Message = message; }
internal DropboxDeployInfo GetDeployInfo(string path, OAuthInfo oauth, AccountInfo account, string cursor = null) { List<DropboxEntryInfo> deltas = new List<DropboxEntryInfo>(); string timeStamp = GetUtcTimeStamp(); string oldCursor = cursor; string newCursor = ""; while (true) { DeltaInfo delta = GetDeltaInfo(oauth, cursor); newCursor = delta.cursor; if (newCursor == oldCursor) { break; } foreach (EntryInfo info in delta.entries) { DropboxEntryInfo item = new DropboxEntryInfo(); if (info.metadata != null && !info.metadata.path.StartsWith(path)) { continue; } if (info.metadata == null || info.metadata.is_deleted || string.IsNullOrEmpty(info.metadata.path)) { item.Path = info.path; item.IsDeleted = true; } else { item.Path = info.metadata.path; item.IsDirectory = info.metadata.is_dir; if (!item.IsDirectory) { item.Modified = info.metadata.modified; item.Nonce = GetNonce(); item.Signature = GetSignature(oauth, info.path, timeStamp, item.Nonce); } } deltas.Add(item); } if (!delta.has_more) { break; } cursor = newCursor; } if (deltas.Count == 0) { throw new InvalidOperationException("the repo is up-to-date."); } var deployInfo = new DropboxDeployInfo { TimeStamp = timeStamp, Token = oauth.Token, ConsumerKey = oauth.ConsumerKey, OAuthVersion = "1.0", SignatureMethod = "HMAC-SHA1", OldCursor = oldCursor, NewCursor = newCursor, Path = path, UserName = account.display_name, Email = account.email, }; deployInfo.Deltas.AddRange(deltas); return deployInfo; }
private void TwitterAuthOpen() { if (CheckTwitterAccounts()) { try { OAuthInfo oauth = new OAuthInfo(APIKeys.TwitterConsumerKey, APIKeys.TwitterConsumerSecret); string url = new Twitter(oauth).GetAuthorizationURL(); if (!string.IsNullOrEmpty(url)) { oauth.Description = Config.TwitterOAuthInfoList[Config.TwitterSelectedAccount].Description; Config.TwitterOAuthInfoList[Config.TwitterSelectedAccount] = oauth; URLHelpers.OpenURL(url); DebugHelper.WriteLine("TwitterAuthOpen - Authorization URL is opened: " + url); } else { DebugHelper.WriteLine("TwitterAuthOpen - Authorization URL is empty."); } } catch (Exception ex) { MessageBox.Show(ex.ToString(), Resources.UploadersConfigForm_Error, MessageBoxButtons.OK, MessageBoxIcon.Error); } } }
public void JiraAuthOpen() { try { OAuthInfo oauth = new OAuthInfo(APIKeys.JiraConsumerKey); oauth.SignatureMethod = OAuthInfo.OAuthInfoSignatureMethod.RSA_SHA1; oauth.ConsumerPrivateKey = Jira.PrivateKey; string url = new Jira(Config.JiraHost, oauth).GetAuthorizationURL(); if (!string.IsNullOrEmpty(url)) { Config.JiraOAuthInfo = oauth; URLHelpers.OpenURL(url); } } catch (Exception ex) { MessageBox.Show(ex.ToString(), Resources.UploadersConfigForm_Error, MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private string GetSignature(OAuthInfo oauth, string path, string timeStamp, string nonce) { var strb = new StringBuilder(); strb.AppendFormat("{0}={1}", "oauth_consumer_key", oauth.ConsumerKey); strb.AppendFormat("&{0}={1}", "oauth_nonce", nonce); strb.AppendFormat("&{0}={1}", "oauth_signature_method", "HMAC-SHA1"); strb.AppendFormat("&{0}={1}", "oauth_timestamp", timeStamp); strb.AppendFormat("&{0}={1}", "oauth_token", oauth.Token); strb.AppendFormat("&{0}={1}", "oauth_version", "1.0"); string data = String.Format("{0}&{1}&{2}", "GET", UrlEncode("https://api-content.dropbox.com/1/files/sandbox" + DropboxPathEncode(path.ToLower())), UrlEncode(strb.ToString())); var key = String.Format("{0}&{1}", UrlEncode(oauth.ConsumerSecret), UrlEncode(oauth.TokenSecret)); HMACSHA1 hmacSha1 = new HMACSHA1(); hmacSha1.Key = Encoding.ASCII.GetBytes(key); byte[] hashBytes = hmacSha1.ComputeHash(Encoding.ASCII.GetBytes(data)); return Convert.ToBase64String(hashBytes); }
public void PhotobucketAuthOpen() { try { OAuthInfo oauth = new OAuthInfo(APIKeys.PhotobucketConsumerKey, APIKeys.PhotobucketConsumerSecret); string url = new Photobucket(oauth).GetAuthorizationURL(); if (!string.IsNullOrEmpty(url)) { Config.PhotobucketOAuthInfo = oauth; URLHelpers.OpenURL(url); } } catch (Exception ex) { MessageBox.Show(ex.ToString(), Resources.UploadersConfigForm_Error, MessageBoxButtons.OK, MessageBoxIcon.Error); } }
public Copy(OAuthInfo oauth, CopyAccountInfo accountInfo) : this(oauth) { AccountInfo = accountInfo; }
/// <summary> /// 创建开放授权用户 /// </summary> /// <param name="oauthInfo">开放授权信息</param> public static void CreateOAuthUser(OAuthInfo oauthInfo) { BrnMall.Core.BMAData.RDBS.CreateOAuthUser(oauthInfo); }
private void DoAfterUploadJobs() { try { if (Info.TaskSettings.AfterUploadJob.HasFlag(AfterUploadTasks.UseURLShortener) || Info.Job == TaskJob.ShortenURL || (Info.TaskSettings.AdvancedSettings.AutoShortenURLLength > 0 && Info.Result.URL.Length > Info.TaskSettings.AdvancedSettings.AutoShortenURLLength)) { UploadResult result = ShortenURL(Info.Result.URL); if (result != null) { Info.Result.ShortenedURL = result.ShortenedURL; } } if (Info.TaskSettings.AfterUploadJob.HasFlag(AfterUploadTasks.ShareURLToSocialNetworkingService)) { OAuthInfo twitterOAuth = Program.UploadersConfig.TwitterOAuthInfoList.ReturnIfValidIndex(Program.UploadersConfig.TwitterSelectedAccount); if (twitterOAuth != null) { using (TwitterMsg twitter = new TwitterMsg(twitterOAuth)) { twitter.Message = Info.Result.ToString(); twitter.Config = Program.UploadersConfig.TwitterClientConfig; twitter.ShowDialog(); } } } if (Info.TaskSettings.AfterUploadJob.HasFlag(AfterUploadTasks.SendURLWithEmail)) { using (EmailForm emailForm = new EmailForm(Program.UploadersConfig.EmailRememberLastTo ? Program.UploadersConfig.EmailLastTo : string.Empty, Program.UploadersConfig.EmailDefaultSubject, Info.Result.ToString())) { emailForm.Icon = ShareXResources.Icon; if (emailForm.ShowDialog() == DialogResult.OK) { if (Program.UploadersConfig.EmailRememberLastTo) { Program.UploadersConfig.EmailLastTo = emailForm.ToEmail; } Email email = new Email { SmtpServer = Program.UploadersConfig.EmailSmtpServer, SmtpPort = Program.UploadersConfig.EmailSmtpPort, FromEmail = Program.UploadersConfig.EmailFrom, Password = Program.UploadersConfig.EmailPassword }; email.Send(emailForm.ToEmail, emailForm.Subject, emailForm.Body); } } } if (Info.TaskSettings.AfterUploadJob.HasFlag(AfterUploadTasks.CopyURLToClipboard)) { string txt; if (!string.IsNullOrEmpty(Info.TaskSettings.AdvancedSettings.ClipboardContentFormat)) { txt = new UploadInfoParser().Parse(Info, Info.TaskSettings.AdvancedSettings.ClipboardContentFormat); } else { txt = Info.Result.ToString(); } if (!string.IsNullOrEmpty(txt)) { ClipboardHelpers.CopyText(txt); } } } catch (Exception e) { DebugHelper.WriteException(e); if (Info.Result == null) { Info.Result = new UploadResult(); } Info.Result.Errors.Add(e.ToString()); } }
protected string GetAuthorizationURL(string requestTokenURL, string authorizeURL, OAuthInfo authInfo, Dictionary <string, string> customParameters = null, HttpMethod httpMethod = HttpMethod.GET) { string url = OAuthManager.GenerateQuery(requestTokenURL, customParameters, httpMethod, authInfo); string response = SendRequest(httpMethod, url); if (!string.IsNullOrEmpty(response)) { return(OAuthManager.GetAuthorizationURL(response, authInfo, authorizeURL)); } return(null); }
public Photobucket(OAuthInfo oauth) { AuthInfo = oauth; AccountInfo = new PhotobucketAccountInfo(); }
private void TwitterAccountAddButton_Click(object sender, EventArgs e) { OAuthInfo acc = new OAuthInfo(); Config.TwitterOAuthInfoList.Add(acc); ucTwitterAccounts.AddItem(acc); }
public TwitSnapsUploader(string apiKey, OAuthInfo oauth) { APIKey = apiKey; AuthInfo = oauth; }
private void btnTwitterAdd_Click(object sender, EventArgs e) { OAuthInfo oauth = new OAuthInfo(); Config.TwitterOAuthInfoList.Add(oauth); lvTwitterAccounts.Items.Add(oauth.Description); lvTwitterAccounts.SelectLast(); TwitterUpdateSelected(); }
public Photobucket(OAuthInfo oauth, PhotobucketAccountInfo accountInfo) : this(oauth) { AccountInfo = accountInfo; }
public Twitter(OAuthInfo oauth) { AuthInfo = oauth; }
public Photobucket(OAuthInfo oauth) { AuthInfo = oauth; }
private HttpClient GetDropboxClient(HttpMethod method, Uri uri, OAuthInfo oauth, params KeyValuePair<string, string>[] query) { var parameters = new Dictionary<string, string> { { "oauth_consumer_key", oauth.ConsumerKey }, { "oauth_signature_method", "HMAC-SHA1" }, { "oauth_timestamp", GetUtcTimeStamp() }, { "oauth_nonce", GetNonce() }, { "oauth_version", "1.0" }, }; if (!string.IsNullOrEmpty(oauth.Token)) { parameters["oauth_token"] = oauth.Token; } var pp = new Dictionary<string, string>(parameters); foreach (KeyValuePair<string, string> pair in query) { pp.Add(pair.Key, pair.Value); } var strb = new StringBuilder(); foreach (var pair in pp.OrderBy(pair => pair.Key, StringComparer.OrdinalIgnoreCase)) { if (strb.Length != 0) { strb.Append('&'); } strb.AppendFormat("{0}={1}", pair.Key, pair.Value); } string data = string.Format( "{0}&{1}&{2}", method.ToString().ToUpperInvariant(), UrlEncode(uri.AbsoluteUri.Split('?')[0]), UrlEncode(strb.ToString())); string key = string.Format( "{0}&{1}", UrlEncode(oauth.ConsumerSecret), string.IsNullOrEmpty(oauth.TokenSecret) ? string.Empty : UrlEncode(oauth.TokenSecret)); HMACSHA1 hmacSha1 = new HMACSHA1(); hmacSha1.Key = Encoding.ASCII.GetBytes(key); byte[] hashBytes = hmacSha1.ComputeHash(Encoding.ASCII.GetBytes(data)); parameters.Add("oauth_signature", Convert.ToBase64String(hashBytes)); strb = new StringBuilder(); foreach (KeyValuePair<string, string> pair in parameters) { if (strb.Length != 0) { strb.Append(','); } strb.AppendFormat("{0}=\"{1}\"", pair.Key, pair.Value); } var client = new HttpClient(); client.BaseAddress = new Uri(string.Format("{0}://{1}", uri.Scheme, uri.Host)); client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("OAuth", strb.ToString()); return client; }
public Copy(OAuthInfo oauth) { AuthInfo = oauth; }
public static void Main(string[] args) { //Load config XmlData config; try { config=new XmlData("tweetstatus.xml"); } catch(Exception e) { Console.WriteLine("Konfiguration konnte nicht gelesen werden."); Console.WriteLine(e.ToString()); return; } string miscCheckCertificates=config.GetElementAsString("xml.misc.checkcertificates"); if(miscCheckCertificates.ToLower()=="false") { //Disable certificate check ServicePointManager.ServerCertificateValidationCallback=delegate { return true; }; } string apiToken=config.GetElementAsString("xml.api.token"); string apiUrl=config.GetElementAsString("xml.api.url"); string twitterConsumerKey=config.GetElementAsString("xml.twitter.consumerkey"); string twitterConsumerSecret=config.GetElementAsString("xml.twitter.consumersecret"); string twitterAccessToken=config.GetElementAsString("xml.twitter.accesstoken"); string twitterAccessTokenSecret=config.GetElementAsString("xml.twitter.accesstokensecret"); //Create twitter token OAuthInfo token=null; if(twitterAccessToken==""||twitterAccessTokenSecret=="") { Console.WriteLine("Set access token in config file"); return; } else { token=new OAuthInfo { AccessToken=twitterAccessToken, AccessSecret=twitterAccessTokenSecret, ConsumerKey=twitterConsumerKey, ConsumerSecret=twitterConsumerSecret }; } //Check status database Console.WriteLine("Check status database"); //Database RestClient client=new RestClient(apiUrl); string parameters=String.Format("entities/?token={0}", apiToken); string value=client.Request(parameters); int entityCount=Convert.ToInt32(value); Console.WriteLine("Entity count from api: {0}", entityCount); //Check status file and tweet if nessesary //Load known entries string entryFile="status.txt"; Entry oldStatus=new Entry(0); if(File.Exists(entryFile)) { oldStatus=new Entry(File.ReadAllLines(entryFile)[0]); } Entry newStatus=new Entry(entityCount); if(oldStatus!=newStatus) { //Tweet DateTime now=DateTime.Now; string datetimeHash="#"+CRC16.ComputeChecksum(BitConverter.GetBytes(now.Ticks)).ToString("x4"); string statusGreen=String.Format("Der Hackerspace ist besetzt ({0}:{1:00} Uhr) und kann besucht werden. #status {2}", now.Hour, now.Minute, datetimeHash); string statusYellow=""; string statusRed=String.Format("Der Hackerspace ist nicht mehr besetzt ({0}:{1:00} Uhr). #status {2}", now.Hour, now.Minute, datetimeHash); string tweetText=""; if(newStatus.EntityCount==0) { tweetText=statusRed; } else { if(oldStatus.EntityCount>0) { Console.WriteLine("Update not necessary."); return; } tweetText=statusGreen; } bool success=true; try { Console.WriteLine("Token: {0}", token.ToString()); var twitter=new TinyTwitter.TinyTwitter(token); twitter.UpdateStatus(tweetText); } catch(Exception ex) { Console.WriteLine(ex.ToString()); success=false; } if(success) { //Write success on console Console.WriteLine("Tweet sended: {0}", tweetText); //Write new status File.WriteAllText(entryFile, newStatus.ToString()); } else { Console.WriteLine("Tweet not sended: {0}", tweetText); } } }
protected bool GetAccessToken(string accessTokenURL, OAuthInfo authInfo, HttpMethod httpMethod = HttpMethod.GET) { return GetAccessTokenEx(accessTokenURL, authInfo, httpMethod) != null; }
private void TwitterAuthClear() { if (CheckTwitterAccounts()) { OAuthInfo oauth = new OAuthInfo(); OAuthInfo oauth2 = GetSelectedTwitterAccount(); if (oauth2 != null) { oauth.Description = oauth2.Description; } Config.TwitterOAuthInfoList[Config.TwitterSelectedAccount] = oauth; } }
protected NameValueCollection GetAccessTokenEx(string accessTokenURL, OAuthInfo authInfo, HttpMethod httpMethod = HttpMethod.GET) { if (string.IsNullOrEmpty(authInfo.AuthToken) || string.IsNullOrEmpty(authInfo.AuthSecret)) { throw new Exception("Auth infos missing. Open Authorization URL first."); } string url = OAuthManager.GenerateQuery(accessTokenURL, null, httpMethod, authInfo); string response = SendRequest(httpMethod, url); if (!string.IsNullOrEmpty(response)) { return OAuthManager.ParseAccessTokenResponse(response, authInfo); } return null; }
public void CopyAuthOpen() { try { OAuthInfo oauth = new OAuthInfo(APIKeys.CopyConsumerKey, APIKeys.CopyConsumerSecret); string url = new Copy(oauth).GetAuthorizationURL(); if (!string.IsNullOrEmpty(url)) { Config.CopyOAuthInfo = oauth; URLHelpers.OpenURL(url); DebugHelper.WriteLine("CopyAuthOpen - Authorization URL is opened: " + url); } else { DebugHelper.WriteLine("CopyAuthOpen - Authorization URL is empty."); } } catch (Exception ex) { MessageBox.Show(ex.ToString(), Resources.UploadersConfigForm_Error, MessageBoxButtons.OK, MessageBoxIcon.Error); } }
protected string GetAuthorizationURL(string requestTokenURL, string authorizeURL, OAuthInfo authInfo, Dictionary<string, string> customParameters = null, HttpMethod httpMethod = HttpMethod.GET) { string url = OAuthManager.GenerateQuery(requestTokenURL, customParameters, httpMethod, authInfo); string response = SendRequest(httpMethod, url); if (!string.IsNullOrEmpty(response)) { return OAuthManager.GetAuthorizationURL(response, authInfo, authorizeURL); } return null; }
public TwitterTweetForm(OAuthInfo oauth) : this() { AuthInfo = oauth; }
public void TwitterAuthOpen() { if (CheckTwitterAccounts()) { OAuthInfo acc = new OAuthInfo(APIKeys.TwitterConsumerKey, APIKeys.TwitterConsumerSecret); Twitter twitter = new Twitter(acc); string url = twitter.GetAuthorizationURL(); if (!string.IsNullOrEmpty(url)) { acc.Description = Config.TwitterOAuthInfoList[Config.TwitterSelectedAccount].Description; Config.TwitterOAuthInfoList[Config.TwitterSelectedAccount] = acc; ucTwitterAccounts.pgSettings.SelectedObject = acc; URLHelpers.OpenURL(url); btnTwitterLogin.Enabled = true; } } }
public override bool CheckConfig(UploadersConfig config) { return(config.PhotobucketAccountInfo != null && OAuthInfo.CheckOAuth(config.PhotobucketOAuthInfo)); }
private DropboxDeployInfo GetDeployInfo(OAuthInfo oauth, string cursor = null) { List<DropboxDeltaInfo> deltas = new List<DropboxDeltaInfo>(); string timeStamp = GetUtcTimeStamp(); string oldCursor = cursor; string newCursor = ""; while (true) { DeltaInfo delta = GetDeltaInfo(oauth, cursor); newCursor = delta.cursor; if (newCursor == oldCursor) { break; } foreach (EntryInfo info in delta.entries) { DropboxDeltaInfo item = new DropboxDeltaInfo { Path = info.path }; if (info.metadata == null || info.metadata.is_deleted || string.IsNullOrEmpty(info.metadata.path)) { item.IsDeleted = true; } else { item.IsDirectory = info.metadata.is_dir; if (!item.IsDirectory) { item.Modified = info.metadata.modified; item.Nonce = GetNonce(); item.Signature = GetSignature(oauth, info.path, timeStamp, item.Nonce); } } deltas.Add(item); } if (!delta.has_more) { break; } } if (deltas.Count == 0) { throw new InvalidOperationException("the repo is up-to-date."); } return new DropboxDeployInfo { TimeStamp = timeStamp, Token = oauth.Token, ConsumerKey = oauth.ConsumerKey, OAuthVersion = "1.0", SignatureMethod = "HMAC-SHA1", OldCursor = oldCursor, NewCursor = newCursor, Path = "/", Deltas = deltas }; }
public Photobucket(OAuthInfo oauth, PhotobucketAccountInfo accountInfo) { AuthInfo = oauth; AccountInfo = accountInfo; }
protected bool GetAccessToken(string accessTokenURL, OAuthInfo authInfo, HttpMethod httpMethod = HttpMethod.GET) { return(GetAccessTokenEx(accessTokenURL, authInfo, httpMethod) != null); }
public Jira(string jiraBaseAddress, OAuthInfo oauth, string jiraIssuePrefix = null) { _jiraBaseAddress = jiraBaseAddress; AuthInfo = oauth; _jiraIssuePrefix = jiraIssuePrefix; InitUris(); }