How to create a simple share linkedIn link?
Asked Answered
L

8

9

I am using the followings for twitter, facebook and google+ but the linkedin gives me an error dialog box:

<a class="btn btn-default icon" href="javascript:void(0)" onclick="window.open( 'http://www.twitter.com/share?url=<?php the_permalink(); ?>', 'sharer', 'toolbar=0, status=0, width=626, height=436');return false;" title="Share on Twitter"><span class="character">a</span></a>

<a class="btn btn-default icon" href="javascript:void(0)" onclick="window.open( 'http://www.facebook.com/sharer.php?u=<?php the_permalink(); ?>', 'sharer', 'toolbar=0, status=0, width=626, height=436');return false;" title="Share on Facebook"><span class="character">b</span></a>

<a class="btn btn-default icon" href="javascript:void(0)" onclick="window.open( 'https://plus.google.com/share?url=<?php the_permalink(); ?>', 'sharer', 'toolbar=0, status=0, width=626, height=436');return false;" title="Share on Google+"><span class="character">c</span></a>

<a class="btn btn-default icon" href="javascript:void(0)" onclick="window.open( 'https://www.linkedin.com/share?url=<?php the_permalink(); ?>', 'sharer', 'toolbar=0, status=0, width=626, height=436');return false;" title="Share on Google+"><span class="character">j</span></a>

Error

This XML file does not appear to have any style information associated with it. The document tree is shown below.

<WSResponse>
  <responseInfo>FAILURE_NO_SUBMIT_ACTION</responseInfo> <responseMsg/>
  <jsonPayLoad/> 
</WSResponse>

Note

<?php the_permalink(); ?> renders the link of the current site page that you could share on socials networks

Lona answered 20/4, 2015 at 9:30 Comment(4)
error comes from the webservice you call, so it isn't js or jquery issue for me. Please provide us the call to the webservice that gives you this errorNanananak
not sure what that error means, do you know how to create a share link with js for linkedIn?Lona
what is the the_permalink(); for linkedin? what is the result/render of this php page in html?Nanananak
the <?php the_permalink(); ?> renders the link of the current site page that you could share on socials networks - I'll update the question with this infoLona
V
21

I think the problem is you are not doing it in the way linkedin asked to you. You should always refer to API docs first. For example below linkedin describe how you can generate Share Plugin for your site.

Share Plugin Generator

and the code generated is looks like:

<script src="//platform.linkedin.com/in.js" type="text/javascript"> lang: en_US</script>
<script type="IN/Share" data-url="Your_URL_Here" data-counter="top"></script>

Also you can do it in following way:

https://www.linkedin.com/shareArticle?mini=true&url=http://developer.linkedin.com&title=LinkedIn%20Developer%20Network&summary=My%20favorite%20developer%20program&source=LinkedIn

Reference: Share on Linkedin

Your link will look like:

https://www.linkedin.com/shareArticle?mini=true&url=<?php the_permalink(); ?>&title=Some%20Title&summary=Some%20Summary&source=YourWebsiteName

Where mini parameter is for: A required argument who's value must always be: true

and Source is: The url-encoded source of the content (e.g. your website or application name) Please let me know if you still needs to know how it will work for you.

And all parameters must be URL Encoded.

Victual answered 20/4, 2015 at 9:46 Comment(3)
i see... so how do i generate the link afterwards?Lona
Please look into Share on Linkedin link I gave to you. It has URL that you need to use. and ignore Share Plugin GeneratorVictual
Please be careful.if URL has Special characters((persian or arabic ...font)) you can not share it in linkedinCallboard
T
7

I use this very simple sharer:

<a href="https://www.linkedin.com/sharing/share-offsite/?url=your-url-here.com"target="_blank" title="Share on LinkedIn">
Share on LinkedIn
</a>

This is how it looks like: Example of using simple LinkedIn sharer in Google Chrome

Trishatriskelion answered 29/9, 2018 at 14:16 Comment(0)
G
5

You can just change in onclick url linkedin 'share?url=' to 'shareArticle?mini=true&', i think it's help.

<a class="btn btn-default icon" href="javascript:void(0)" onclick="window.open( 'http://www.linkedin.com/shareArticle?mini=true&url=<?php the_permalink(); ?>', 'sharer', 'toolbar=0, status=0, width=626, height=436');return false;" title="Linkedin"><span class="character">j</span></a>
Ganesa answered 20/4, 2015 at 10:3 Comment(0)
X
1

Step 1 - Get the URL Right

Use this URL format...

https://www.linkedin.com/sharing/share-offsite/?url={url}

Source: Official MSD LinkedIn Share Documentation

Step 2 - Handle title, description, image, etc.

Set your og: tags in the <head> block of your HTML, like so...

  • <meta property='og:title' content='Title of the article'/>
  • <meta property='og:image' content='//media.example.com/ 1234567.jpg'/>
  • <meta property='og:description' content='Description that will show in the preview'/>
  • <meta property='og:url' content='//www.example.com/URL of the article' />

Source: LinkedIn Share Documentation: Making Your Website Shareable on LinkedIn

Step 3 - Verify Everything Went Okay

Use the LinkedIn Post Inspector. Insert your URL here (example.com), not the URL you are going to share with (linkedin.com?url=example.com).

Xl answered 31/7, 2020 at 18:25 Comment(0)
N
0

You should better use the linkeidn script, or see what he generate exactly

<script src="//platform.linkedin.com/in.js" type="text/javascript"> lang: en_US</script>
<script type="IN/Share" data-url="<?php the_permalink(); ?>" data-counter="top"></script>

source: linkedin developper

Nanananak answered 20/4, 2015 at 9:39 Comment(0)
K
0

This script to be added at the top

<script src="//platform.linkedin.com/in.js" type="text/javascript"> lang:en_US</script>

and if you want to use linkedin button on a popup then you have to insert following script in the html.

<script type="IN/Share" data-url="http://linkedin.com">
            </script>
Kaufmann answered 20/2, 2017 at 12:26 Comment(0)
C
0

I use this style on my blogger posts

<a style="text-decoration:none;color: #0095ff;display: flex; flex-wrap: nowrap; align-content: center; justify-content: flex-start; align-items: flex-end; background-color: #f3f3f3; border: 4px solid #ededed; width: fit-content; padding: 2px; border-radius: 10px;" href="https://www.linkedin.com/sharing/share-offsite/?url=https://www.muratatasoy.com.tr/2023/04/tum-resimleri-powerpoint-slaytlarna.html" target="_blank" title="Share on LinkedIn">
Linked<svg height="24px" preserveaspectratio="xMinYMin meet" viewbox="0 0 24 24" width="24px" x="0" y="0"><g style="fill: currentcolor;"><rect height="24" style="fill: none;" width="24" x="-0.003"></rect><path d="M20,2h-16c-1.1,0-2,0.9-2,2v16c0,1.1,0.9,2,2,2h16c1.1,0,2-0.9,2-2V4C22,2.9,21.1,2,20,2zM8,19h-3v-9h3V19zM6.5,8.8C5.5,8.8,4.7,8,4.7,7s0.8-1.8,1.8-1.8S8.3,6,8.3,7S7.5,8.8,6.5,8.8zM19,19h-3v-4c0-1.4-0.6-2-1.5-2c-1.1,0-1.5,0.8-1.5,2.2V19h-3v-9h2.9v1.1c0.5-0.7,1.4-1.3,2.6-1.3c2.3,0,3.5,1.1,3.5,3.7V19z"></path></g></svg></a>
Canto answered 29/4, 2023 at 7:57 Comment(0)
M
-1

I got it to work like this (very simple):

 <a target="_blank" title="Share on LinkedIn"
     href="http://www.linkedin.com/shareArticle?mini=true&url={{your-content-here.com}}">
 </a>

this will open a new tab (at least in Chrome), and looks like this:

enter image description here

In my case, is a link to Chrome Webstorm item url. Because I'd like share my Chrome Extension App, on various social media sites.

Minuend answered 8/2, 2018 at 7:57 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.