Search code examples
javascriptlinkedin-apilinkedin-jsapi

Linkedin share count button secureAnonymousFramework error


I'm implementing linked in share count button to web page. Here is HTML and JS code i have

<li>
    <script type="IN/Share" data-url="<?php echo $linkedin_url; ?>" id="<?php echo $id; ?>" data-counter="top"></script>

    <script>
        debugger;
        if (typeof (IN) != 'undefined') {
            IN.parse();
        } else {
          opjq.getScript("http://platform.linkedin.com/in.js");
        }   
    </script>
</li>

In console i got javascript error

secureAnonymousFramework?v=0.0.2000-RC8.61320-1429&:1406 Uncaught TypeError: Cannot read property 'className' of null
at Object.addClass (secureAnonymousFramework?v=0.0.2000-RC8.61320-1429&:1406)
at B.<anonymous> (secureAnonymousFramework?v=0.0.2000-RC8.61320-1429&:2926)
at B.setContent (secureAnonymousFramework?v=0.0.2000-RC8.61320-1429&:308)
at B.<anonymous> (secureAnonymousFramework?v=0.0.2000-RC8.61320-1429&:1900)
at B.setCountFormatted (secureAnonymousFramework?v=0.0.2000-RC8.61320-1429&:308)
at o (secureAnonymousFramework?v=0.0.2000-RC8.61320-1429&:1937)
at b (secureAnonymousFramework?v=0.0.2000-RC8.61320-1429&:1939)
at Function.handleCount (secureAnonymousFramework?v=0.0.2000-RC8.61320-1429&:1908)
at share?url=http%3A%2F%theme.app%2Fwp-admin%2Fadmin.php%3Fpage%page-b…:1

Does anyone know something about this error?


Solution

  • I get the same error message when I try to test in local. There is a regex in the secureAnonymous javascript file, which tries to detect from which page you are currently. (https://platform.linkedin.com/js/secureAnonymousFramework) It failed when the protocol starts with 'file://'. On remote host, it will work correctly.