protected void btnURLShare_Click(object sender, EventArgs e) { LinkedInLibrary.BaseRequest.Post <LinkedInShare, LinkedInErrorResponse>( LinkedInLibrary.Constants.URLs._ugcposts, lblAccessToken.Text, () => { LinkedInTextShareRequest requestbody = new LinkedInTextShareRequest(); requestbody.author = String.Format("urn:li:person:{0}", lblUserID.Text); requestbody.specificContent.shareContent.shareCommentary.text = txtURLShareComment.Text; requestbody.specificContent.shareContent.shareMediaCategory = "ARTICLE"; Media media = new Media(); media.description.text = txtURLShareDescription.Text; media.originalUrl = txtURLShareURL.Text; media.title.text = txtURLShareTitle.Text; requestbody.specificContent.shareContent.media = new List <Media>() { media }; string s = JsonConvert.SerializeObject(requestbody); return(new StringContent(s, Encoding.UTF8, "application/json")); }, (LinkedInShare share) => { divError.Visible = false; divSuccess.Visible = true; lblShareURN.Text = share.ShareURN; btnGetPost.Visible = true; return(null); }, HandleErrorResponse ); }
/* * WORKING */ #region User Text Post protected void btnTextShare_Click(object sender, EventArgs e) { if (!String.IsNullOrEmpty(lblAccessToken.Text) && !String.IsNullOrEmpty(lblUserID.Text)) { LinkedInTextShareRequest requestbody = new LinkedInTextShareRequest(); requestbody.author = String.Format("urn:li:person:{0}", lblUserID.Text); requestbody.specificContent.shareContent.shareCommentary.text = txtTextShare.Text; LinkedInLibrary.BaseRequest.Post <LinkedInShare, LinkedInErrorResponse>(LinkedInLibrary.Constants.URLs._ugcposts, lblAccessToken.Text, () => { string s = JsonConvert.SerializeObject(requestbody); return(new StringContent(s, Encoding.UTF8, "application/json")); }, (LinkedInShare share) => { divError.Visible = false; divSuccess.Visible = true; lblShareURN.Text = share.ShareURN; return(null); }, HandleErrorResponse); } }