How to create a simple share linkedIn link?

40,865

Solution 1

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.

Solution 2

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

Solution 3

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>
Share:
40,865
rob.m
Author by

rob.m

Updated on July 17, 2022

Comments

  • rob.m
    rob.m almost 2 years

    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