Click here to Skip to main content
15,885,546 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi i want to post message on linkdin,Facebbok and Instagram using asp.net C# / MVC Application
 
I have tried many articles but didnot find any solution, please help me that how can i perform such task,
 
please share if anyone have used such implementation 


What I have tried:

 private string linkedinSharesEndPoint = "https://api.linkedin.com/v1/people/~/shares?oauth2_access_token={0}";
        private const string defaultUrl = "https://www.linkedin.com/in/futuresoft-india-b9b1931bb/";
        private const string defaultImageUrl = "some-image-url";
        string accessToken = "";
        string title = "Post Test";
        protected void Page_Load(object sender, EventArgs e)
        {
            bool r= PostLinkedInNetworkUpdate( accessToken,  title,  defaultUrl, defaultImageUrl);
          if(r)
            {
                string s = "sucess";
            }
        }
       

        public bool PostLinkedInNetworkUpdate(string accessToken, string title, string submittedUrl = defaultUrl, string submittedImageUrl = defaultImageUrl)
        {
           

            var requestUrl = String.Format(linkedinSharesEndPoint, accessToken);
            var message = new
            {
                comment = "Testing out the LinkedIn Share API with JSON",
                content = new Dictionary<string, string>
        { { "title", title },
            { "submitted-url", submittedUrl },
            {"submitted-image-url" , submittedImageUrl}
        },
                visibility = new
                {
                    code = "anyone"
                }
            };

            var requestJson = new JavaScriptSerializer().Serialize(message);

            var client = new WebClient();
            var requestHeaders = new NameValueCollection
    {
        { "Content-Type", "application/json" },
        { "x-li-format", "json" }
    };
            client.Headers.Add(requestHeaders);
            var responseJson = client.UploadString(requestUrl, "POST", requestJson);
            var response = new JavaScriptSerializer().Deserialize<Dictionary<string, object>>(responseJson);
            return response.ContainsKey("updateKey");
        }
    }
I have use this but when i posting, i am getting 401 error(Authincation error)
Posted
Comments
[no name] 6-Nov-20 2:48am    
Do the same thing for the other 2.
Richard MacCutchan 6-Nov-20 6:28am    
You need to check that your authentication values are correct for the website, and their API. Not something that anyone here can do for you.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900