Click here to Skip to main content
15,936,758 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I have to post image to the linkedin from my asp.net mvc applicaiton.


What I have tried:

JavaScript
<blockquote class="quote"><div class="op">Quote:</div> function ShareLinkedIn() {
            var Array = $('#VacancyGrid [name=id]:checked').map(function() {
                return $(this).val();
            }).get();

            if (Array == "") {
                showAlertMessage("Alert", "Please select vacancy."); // alert();
            } else {

                $.ajax({
                    url: '@Url.Action("LinkedINAuth", "Vacancy")',
                    data: { vacancyIds: Array.toString() },
                    async: true,
                    type: 'POST',
                    cache: false,
                    success: function(datas) {
                        debugger;
                        var html = datas.split(',')[0].toString();
                        var image = datas.split(',')[1].toString();
                        //txp2rKYpuKZXaaYC5kB-m13KnVE Initialize with your OAuth.io app public key  QdDTUvqmt2uX6kg4M5Fonvyn7c4
                        OAuth.initialize('txp2rKYpuKZXaaYC5kB-m13KnVE');
                        // $('#auth').show();
                        OAuth.popup('linkedin2').then(linkedin => {
                            console.log('linkedin:', linkedin);
                        // Get your linkedin profile id:
                        linkedin.me().then(data => {
                            let id = data.id;
                        linkedin.post({
                            url: "/v2/shares",
                            data: JSON.stringify({
                                "content": {
                                    "contentEntities": [
                                        {
                                            "description": "We are hiring Deserving candidate for Dubai Location",
                                            "entityLocation": html,
                                            "thumbnails": [
                                                {
                                                    "imageSpecificContent": {
                                                        "width": 1200,
                                                        "height": 628
                                                    },
                                                    "resolvedUrl": image
                                                }
                                            ]
                                        }
                                    ],
                                    "title": "Current Hiring"
                                },
                                "distribution": {
                                    "linkedInDistributionTarget": {}
                                },
                                "owner": `urn:li:person:${id}`,
                                "subject": "Current Hiring",
                                "text": {
                                    "text": "Current Hiring!"
                                }
                    }),
                headers: {
                    "x-li-format": "json",
                    "X-Restli-Protocol-Version": "2.0.0",
                    "Content-Type": "application/json"
                }
            }).then(data => {
                console.log("success:", data);
        }).fail(err => { console.log("err:", err) });
        });
        });
        }
        });

        }
        }</blockquote>
Posted
Updated 21-Sep-22 2:08am
Comments
Richard MacCutchan 15-Nov-19 3:14am    
Most likely by using linkedin's published interface.
prakash00060 15-Nov-19 4:08am    
have you any solution
prakash00060 15-Nov-19 8:41am    
have you any other options in asp.net mvc

I would look into using the LinkedIn API, which is well documented by MicroSoft:
Share on LinkedIn - LinkedIn | Microsoft Docs[^]
 
Share this answer
 
Comments
prakash00060 15-Nov-19 8:41am    
have you any other options in asp.net mvc
There is a great NuGet Packages available + find code samples here

Super Easy Way to Automate Posting on LinkedIn with .Net - CodeHelper[^]

Quick explanation
1. You create your LinkedInHelper by giving your access token
2. Execute the ShareImage Method

C#
LinkedInHelper _helper = new() { AccessToken = "AQVjgglPI-......" };
var _id = await _helper.GetAuthorID();
_helper.AuthorType = AuthorTypes.Company;
byte[] _image = File.ReadAllBytes(@"c.\...\LinkedIntestImage.jpeg");
await _helper.ShareImage("Welcome LinkedIn Image Share", _image, VisibilityTypes.Public, "My Image Title", "MyImage Description");
 
Share this answer
 

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