Result

How do I get LinkedIn counters?

I tried to count the number of LinkedIn followers using JavaScript:

<div id="statusDiv">Result</div><script type="text/javascript"  src="http://platform.linkedin.com/in.js">
                api_key: XXXXX
onLoad: onLinkedInLoad
authorize: true
</script>
<script type="text/javascript">
function onLinkedInLoad() {
  IN.API.Raw("/companies/<<company_id>>:(num-followers)")
.result( function(result) { document.getElementById("statusDiv").innerHTML =  result.numFollowers; } )
.error( function(error) {  document.getElementById("statusDiv").innerHTML = error } );
 }
 </script>

      

but that doesn't work for me.

+3


source to share


1 answer


Your code looks great. Check for errors in the javascript console. I suspect you have not configured the correct Javascript API Domains in your LinkedIn app settings.

Here's a slightly cleaner version of the same code I just saw, successfully running a properly configured LinkedIn app:



<html>
  <head>
    <script src="http://platform.linkedin.com/in.js" type="text/javascript">
      api_key: xxxxxxxxxxxxxx
      onLoad: onLinkedInLoad
      authorize: true
    </script>

    <script type="text/javascript">
        function onLinkedInLoad() {
            IN.API.Raw("/companies/1337:(num-followers)").result(onSuccess).error(onError);
        }

        function onSuccess(data) {
            document.getElementById("statusDiv").innerHTML =  data.numFollowers;
        }

        function onError(error) {
            console.log(error);
        }
    </script>
  </head>

  <body>
    <div id="statusDiv">Result</div>
  </body>
</html>

      

+1


source







All Articles