public string SetPostOnPage(oAuthLinkedIn oauth, string PageId, string post) { string url = "https://api.linkedin.com/v1/companies/" + PageId + "/shares?format=json"; string response = oauth.LinkedProfilePostWebRequest("POST", url, post); return(response); }
public static string ComposeLinkedInMessage(string ImageUrl, long userid, string comment, string ProfileId, string imagepath, Domain.Socioboard.Models.LinkedInAccount _objLinkedInAccount, Model.DatabaseRepository dbr, Domain.Socioboard.Models.User _user) { string json = ""; var img = ""; Domain.Socioboard.Models.LinkedInAccount _LinkedInAccount = _objLinkedInAccount; oAuthLinkedIn _oauth = new oAuthLinkedIn(); _oauth.ConsumerKey = AppSettings.LinkedinConsumerKey; _oauth.ConsumerSecret = AppSettings.LinkedinConsumerSecret; _oauth.Token = _LinkedInAccount.OAuthToken; string PostUrl = "https://api.linkedin.com/v1/people/~/shares?format=json"; if (string.IsNullOrEmpty(ImageUrl)) { json = _oauth.LinkedProfilePostWebRequest("POST", PostUrl, comment); } else { json = _oauth.LinkedProfilePostWebRequestWithImage("POST", PostUrl, comment, ImageUrl); } if (!string.IsNullOrEmpty(json)) { string msg = "feed shared successfully"; return(msg); } else { string msg = "feed has not posted"; return(msg); } }
public IHttpActionResult LinkedInProfileUpdate(LinkedInManager LinkedInManager) { oAuthLinkedIn _oauth = new oAuthLinkedIn(); string json = ""; Domain.Socioboard.Domain.LinkedInAccount _LinkedinAccount = objLinkedInAccountRepository.getLinkedinAccountDetailsById(LinkedInManager.ProfileId); try { _oauth.ConsumerKey = ConfigurationManager.AppSettings["LinkedinApiKey"]; } catch (Exception ex) { Console.WriteLine(ex.Message); logger.Error(ex.Message); } try { _oauth.ConsumerSecret = ConfigurationManager.AppSettings["LinkedinSecretKey"]; } catch (Exception ex) { Console.WriteLine(ex.Message); logger.Error(ex.Message); } _oauth.Token = _LinkedinAccount.OAuthToken; string PostUrl = "https://api.linkedin.com/v1/people/~/shares?format=json"; if (string.IsNullOrEmpty(LinkedInManager.ImageUrl)) { json = _oauth.LinkedProfilePostWebRequest("POST", PostUrl, LinkedInManager.comment); } else { string imagepath = ConfigurationManager.AppSettings["DomainName"].ToString() + Regex.Split(LinkedInManager.ImageUrl, "wwwroot")[1].Replace("\\", "/"); json = _oauth.LinkedProfilePostWebRequestWithImage("POST", PostUrl, LinkedInManager.comment, imagepath); } #region ScheduledMessage if (!string.IsNullOrEmpty(json)) { objScheduledMessage.Id = Guid.NewGuid(); objScheduledMessage.PicUrl = LinkedInManager.ImageUrl; objScheduledMessage.ProfileId = LinkedInManager.ProfileId; objScheduledMessage.ProfileType = "linkedin"; objScheduledMessage.ScheduleTime = DateTime.Now; objScheduledMessage.ShareMessage = LinkedInManager.comment; objScheduledMessage.Status = true; objScheduledMessage.UserId = Guid.Parse(LinkedInManager.UserId); objScheduledMessage.CreateTime = DateTime.Now; objScheduledMessage.ClientTime = DateTime.Now; if (!objScheduledMessageRepository.checkMessageExistsAtTime(objScheduledMessage.UserId, objScheduledMessage.ScheduleTime)) { objScheduledMessageRepository.addNewMessage(objScheduledMessage); } } #endregion return(Ok()); }
public string LinkedInScheduleUpdate(LinkedInManager LinkedInManager) { string json = ""; if (LinkedInManager.ScheduleTime <= DateTime.Now) { oAuthLinkedIn _oauth = new oAuthLinkedIn(); Domain.Socioboard.Domain.LinkedInAccount _LinkedinAccount = objLinkedInAccountRepository.getLinkedinAccountDetailsById(LinkedInManager.ProfileId); try { _oauth.ConsumerKey = ConfigurationManager.AppSettings["LinkedinApiKey"]; } catch (Exception ex) { Console.WriteLine(ex.Message); logger.Error(ex.Message); } try { _oauth.ConsumerSecret = ConfigurationManager.AppSettings["LinkedinSecretKey"]; } catch (Exception ex) { Console.WriteLine(ex.Message); logger.Error(ex.Message); } _oauth.Token = _LinkedinAccount.OAuthToken; string PostUrl = "https://api.linkedin.com/v1/people/~/shares?format=json"; if (string.IsNullOrEmpty(LinkedInManager.ImageUrl)) { json = _oauth.LinkedProfilePostWebRequest("POST", PostUrl, LinkedInManager.comment); } else { string imagepath = ConfigurationManager.AppSettings["DomainName"].ToString() + Regex.Split(LinkedInManager.ImageUrl, "wwwroot")[1].Replace("\\", "/"); json = _oauth.LinkedProfilePostWebRequestWithImage("POST", PostUrl, LinkedInManager.comment, imagepath); } if (!string.IsNullOrEmpty(json)) { json = "Message post on LinkedIn for Id :" + LinkedInManager.ProfileId + " and Message: " + LinkedInManager.comment; objScheduledMessageRepository.UpdateScheduledMessage(Guid.Parse(LinkedInManager.ScheduleMessageId)); } else { json = "Something Went Wrong"; } } return(json); }
public string SetPostOnPage(oAuthLinkedIn oauth, string PageId, string post) { //string response1 = oauth.APIWebRequest("GET", GlobusLinkedinLib.App.Core.Global.GetCompanyUrl, null); //XmlDocument xmlCompany = new XmlDocument(); //xmlCompany.Load(new StringReader(response1)); //string xml = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"; //xml += "<share><visibility><code>anyone</code></visibility><comment>"+post+"</comment></share>"; //string xml = "<?xml version=\"1.0\" encoding=\"UTF-8\"?><share><visibility><code>anyone</code></visibility><comment>" + post + "</comment></share>"; //string url = "https://api.linkedin.com/v1/companies/" + PageId + "/shares"; string url = "https://api.linkedin.com/v1/companies/" + PageId + "/shares?format=json"; string response = oauth.LinkedProfilePostWebRequest("POST", url, post); return(response); }
public static string PostLinkedInMessage(string ImageUrl, long userid, string comment, string ProfileId, string imagepath, Helper.Cache _redisCache, Helper.AppSettings _appSettings, Model.DatabaseRepository dbr) { string json = ""; Domain.Socioboard.Models.LinkedInAccount _LinkedInAccount = Repositories.LinkedInAccountRepository.getLinkedInAccount(ProfileId, _redisCache, dbr); oAuthLinkedIn _oauth = new oAuthLinkedIn(); _oauth.ConsumerKey = _appSettings.LinkedinApiKey; _oauth.ConsumerSecret = _appSettings.LinkedinSecretKey; _oauth.Token = _LinkedInAccount.OAuthToken; string PostUrl = "https://api.linkedin.com/v1/people/~/shares?format=json"; if (string.IsNullOrEmpty(ImageUrl)) { json = _oauth.LinkedProfilePostWebRequest("POST", PostUrl, comment); } else { json = _oauth.LinkedProfilePostWebRequestWithImage("POST", PostUrl, comment, imagepath); } if (!string.IsNullOrEmpty(json)) { ScheduledMessage scheduledMessage = new ScheduledMessage(); scheduledMessage.createTime = DateTime.UtcNow; scheduledMessage.picUrl = ImageUrl; scheduledMessage.profileId = ProfileId; scheduledMessage.profileType = Domain.Socioboard.Enum.SocialProfileType.LinkedIn; scheduledMessage.scheduleTime = DateTime.UtcNow; scheduledMessage.shareMessage = comment; scheduledMessage.userId = userid; scheduledMessage.status = Domain.Socioboard.Enum.ScheduleStatus.Compleated; scheduledMessage.url = json; dbr.Add <ScheduledMessage>(scheduledMessage); return("posted"); } else { json = "Message not posted"; return(json); } }
public static string ComposeLinkedInMessage(string ImageUrl, long userid, string comment, string ProfileId, string imagepath, Domain.Socioboard.Models.LinkedInAccount _objLinkedInAccount, Model.DatabaseRepository dbr, Domain.Socioboard.Models.ScheduledMessage schmessage) { string json = ""; Domain.Socioboard.Models.LinkedInAccount _LinkedInAccount = _objLinkedInAccount; oAuthLinkedIn _oauth = new oAuthLinkedIn(); //_oauth.ConsumerKey = "81k55eukagnqfa"; //_oauth.ConsumerSecret = "d9rqHEf7ewdSbsF1"; _oauth.ConsumerKey = "754ysxdp72ulk5"; _oauth.ConsumerSecret = "vbU52SjK7xS6cT8H"; _oauth.Token = _LinkedInAccount.OAuthToken; string PostUrl = "https://api.linkedin.com/v1/people/~/shares?format=json"; if (string.IsNullOrEmpty(ImageUrl)) { json = _oauth.LinkedProfilePostWebRequest("POST", PostUrl, comment); } else { json = _oauth.LinkedProfilePostWebRequestWithImage("POST", PostUrl, comment, imagepath); } if (!string.IsNullOrEmpty(json)) { apiHitsCount++; schmessage.status = Domain.Socioboard.Enum.ScheduleStatus.Compleated; schmessage.url = json; dbr.Add <ScheduledMessage>(schmessage); return("posted"); } else { apiHitsCount = MaxapiHitsCount; json = "Message not posted"; return(json); } }
public static string ComposeLinkedInMessage(string ImageUrl, long userid, string comment, string ProfileId, string imagepath, Domain.Socioboard.Models.LinkedInAccount _objLinkedInAccount, Model.DatabaseRepository dbr, Domain.Socioboard.Models.ScheduledMessage schmessage) { string json = ""; Domain.Socioboard.Models.LinkedInAccount _LinkedInAccount = _objLinkedInAccount; oAuthLinkedIn _oauth = new oAuthLinkedIn(); _oauth.ConsumerKey = Helper.AppSettings.LinkedinApiKey; _oauth.ConsumerSecret = Helper.AppSettings.LinkedinSecretKey; _oauth.Token = _LinkedInAccount.OAuthToken; string PostUrl = "https://api.linkedin.com/v1/people/~/shares?format=json"; if (string.IsNullOrEmpty(ImageUrl)) { json = _oauth.LinkedProfilePostWebRequest("POST", PostUrl, comment); } else { json = _oauth.LinkedProfilePostWebRequestWithImage("POST", PostUrl, comment, ImageUrl); } if (!string.IsNullOrEmpty(json)) { apiHitsCount++; schmessage.status = Domain.Socioboard.Enum.ScheduleStatus.Compleated; schmessage.url = json; dbr.Update <ScheduledMessage>(schmessage); return("posted"); } else { apiHitsCount = MaxapiHitsCount; json = "Message not posted"; return(json); } }
public static string PostLinkedInMessage(string ImageUrl, long userid, string comment, string ProfileId, string imagepath, Domain.Socioboard.Enum.MediaType mediaType, string profileName, Helper.Cache _redisCache, Helper.AppSettings _appSettings, Model.DatabaseRepository dbr) { try { if (!ImageUrl.Contains("https://") && !ImageUrl.Contains("http://") && !string.IsNullOrEmpty(ImageUrl)) { var client = new ImgurClient("5f1ad42ec5988b7", "f3294c8632ef8de6bfcbc46b37a23d18479159c5"); var endpoint = new ImageEndpoint(client); IImage image; using (var fs = new FileStream(imagepath, FileMode.Open)) { image = endpoint.UploadImageStreamAsync(fs).GetAwaiter().GetResult(); } var img = image.Link; string json = ""; Domain.Socioboard.Models.LinkedInAccount _LinkedInAccount = Repositories.LinkedInAccountRepository.getLinkedInAccount(ProfileId, _redisCache, dbr); oAuthLinkedIn _oauth = new oAuthLinkedIn(); _oauth.ConsumerKey = _appSettings.LinkedinApiKey; _oauth.ConsumerSecret = _appSettings.LinkedinSecretKey; _oauth.Token = _LinkedInAccount.OAuthToken; string PostUrl = "https://api.linkedin.com/v1/people/~/shares?format=json"; if (string.IsNullOrEmpty(ImageUrl)) { json = _oauth.LinkedProfilePostWebRequest("POST", PostUrl, comment); } else { json = _oauth.LinkedProfilePostWebRequestWithImage("POST", PostUrl, comment, img); } if (!string.IsNullOrEmpty(json)) { ScheduledMessage scheduledMessage = new ScheduledMessage(); scheduledMessage.createTime = DateTime.UtcNow; scheduledMessage.picUrl = _LinkedInAccount.ProfileImageUrl; scheduledMessage.profileId = ProfileId; scheduledMessage.profileType = Domain.Socioboard.Enum.SocialProfileType.LinkedIn; scheduledMessage.scheduleTime = DateTime.UtcNow; scheduledMessage.shareMessage = comment; scheduledMessage.userId = userid; scheduledMessage.status = Domain.Socioboard.Enum.ScheduleStatus.Compleated; scheduledMessage.url = ImageUrl; scheduledMessage.mediaType = mediaType; scheduledMessage.socialprofileName = _LinkedInAccount.LinkedinUserName; dbr.Add <ScheduledMessage>(scheduledMessage); return("posted"); } else { json = "Message not posted"; return(json); } } else { string json = ""; Domain.Socioboard.Models.LinkedInAccount _LinkedInAccount = Repositories.LinkedInAccountRepository.getLinkedInAccount(ProfileId, _redisCache, dbr); oAuthLinkedIn _oauth = new oAuthLinkedIn(); _oauth.ConsumerKey = _appSettings.LinkedinApiKey; _oauth.ConsumerSecret = _appSettings.LinkedinSecretKey; _oauth.Token = _LinkedInAccount.OAuthToken; string PostUrl = "https://api.linkedin.com/v1/people/~/shares?format=json"; if (string.IsNullOrEmpty(ImageUrl)) { json = _oauth.LinkedProfilePostWebRequest("POST", PostUrl, comment); } else { var client = new ImgurClient("5f1ad42ec5988b7", "f3294c8632ef8de6bfcbc46b37a23d18479159c5"); var endpoint = new ImageEndpoint(client); IImage image; using (var fs = new FileStream(imagepath, FileMode.Open)) { image = endpoint.UploadImageStreamAsync(fs).GetAwaiter().GetResult(); } var img = image.Link; json = _oauth.LinkedProfilePostWebRequestWithImage("POST", PostUrl, comment, img); } if (!string.IsNullOrEmpty(json)) { ScheduledMessage scheduledMessage = new ScheduledMessage(); scheduledMessage.createTime = DateTime.UtcNow; scheduledMessage.picUrl = _LinkedInAccount.ProfileImageUrl; scheduledMessage.profileId = ProfileId; scheduledMessage.profileType = Domain.Socioboard.Enum.SocialProfileType.LinkedIn; scheduledMessage.scheduleTime = DateTime.UtcNow; scheduledMessage.shareMessage = comment; scheduledMessage.userId = userid; scheduledMessage.status = Domain.Socioboard.Enum.ScheduleStatus.Compleated; scheduledMessage.url = ImageUrl; scheduledMessage.mediaType = mediaType; scheduledMessage.socialprofileName = _LinkedInAccount.LinkedinUserName; dbr.Add <ScheduledMessage>(scheduledMessage); return("posted"); } else { json = "Message not posted"; return(json); } } } catch (Exception ex) { return("Message not posted"); } }
public static string ComposeLinkedInMessage(string ImageUrl, long userid, string comment, string ProfileId, string imagepath, Domain.Socioboard.Models.LinkedInAccount _objLinkedInAccount, Model.DatabaseRepository dbr, Domain.Socioboard.Models.ScheduledMessage schmessage, Domain.Socioboard.Models.User _user) { string json = ""; var img = ""; Domain.Socioboard.Models.LinkedInAccount _LinkedInAccount = _objLinkedInAccount; oAuthLinkedIn _oauth = new oAuthLinkedIn(); _oauth.ConsumerKey = AppSettings.LinkedinApiKey; _oauth.ConsumerSecret = AppSettings.LinkedinSecretKey; _oauth.Token = _LinkedInAccount.OAuthToken; string PostUrl = "https://api.linkedin.com/v1/people/~/shares?format=json"; if (string.IsNullOrEmpty(ImageUrl)) { json = _oauth.LinkedProfilePostWebRequest("POST", PostUrl, comment); } else { var client = new ImgurClient(AppSettings.imgurclietId, AppSettings.imgurclietSecret); var endpoint = new ImageEndpoint(client); IImage image; using (var fs = new FileStream(imagepath, FileMode.Open)) { image = endpoint.UploadImageStreamAsync(fs).GetAwaiter().GetResult(); } var imgs = image.Link; json = _oauth.LinkedProfilePostWebRequestWithImage("POST", PostUrl, comment, imgs); } if (!string.IsNullOrEmpty(json)) { apiHitsCount++; schmessage.status = Domain.Socioboard.Enum.ScheduleStatus.Compleated; schmessage.url = json; dbr.Update <ScheduledMessage>(schmessage); Domain.Socioboard.Models.Notifications notify = new Notifications(); Notifications lstnotifications = dbr.Single <Notifications>(t => t.MsgId == schmessage.id); if (lstnotifications == null) { notify.MsgId = schmessage.id; notify.MsgStatus = "Scheduled"; notify.notificationtime = schmessage.localscheduletime; notify.NotificationType = "Schedule Successfully"; notify.ReadOrUnread = "Unread"; notify.UserId = userid; dbr.Add <Notifications>(notify); if (_user.scheduleSuccessUpdates) { string sucResponse = SendMailbySendGrid(AppSettings.frommail, "", _user.EmailId, "", "", "", "", _user.FirstName, schmessage.localscheduletime, true, AppSettings.sendGridUserName, AppSettings.sendGridPassword); } return("posted"); } else { if (_user.scheduleSuccessUpdates) { string sucResponse = SendMailbySendGrid(AppSettings.frommail, "", _user.EmailId, "", "", "", "", _user.FirstName, schmessage.localscheduletime, true, AppSettings.sendGridUserName, AppSettings.sendGridPassword); } return("posted"); } } else { apiHitsCount = MaxapiHitsCount; json = "Message not posted"; Domain.Socioboard.Models.Notifications notify = new Notifications(); Notifications lstnotifications = dbr.Single <Notifications>(t => t.MsgId == schmessage.id); if (lstnotifications == null) { notify.MsgId = schmessage.id; notify.MsgStatus = "Failed"; notify.notificationtime = schmessage.localscheduletime; notify.NotificationType = "Schedule Failed"; notify.ReadOrUnread = "Unread"; notify.UserId = userid; dbr.Add <Notifications>(notify); if (_user.scheduleFailureUpdates) { string falResponse = SendMailbySendGrid(AppSettings.frommail, "", _user.EmailId, "", "", "", "", _user.FirstName, schmessage.localscheduletime, false, AppSettings.sendGridUserName, AppSettings.sendGridPassword); } return(json); } else { if (_user.scheduleFailureUpdates) { string falResponse = SendMailbySendGrid(AppSettings.frommail, "", _user.EmailId, "", "", "", "", _user.FirstName, schmessage.localscheduletime, false, AppSettings.sendGridUserName, AppSettings.sendGridPassword); } return(json); } } }