Proper share type for st_twitter_hcount and st_fblike_hcount (Dynamic specification through JS)

StackOverflow https://stackoverflow.com/questions/15255827

  •  18-03-2022
  •  | 
  •  

Frage

Here is my test page: http://ignitepixels.com/test/shareThisTest.html

I am having an issue with dynamically generating ShareThis buttons with Javascript. For most of my buttons I want to use the "chicklet" type. But I also want to include the twitter share hcount and facebook like hcount buttons.

Normally (without javascript) you would use something like:

<span class='st_twitter'></span>
<span class='st_facebook'></span>
<span class='st_linkedin'></span>
<span class='st_googleplus'></span>
<span class='st_email'></span>
<span class='st_reddit'></span>
<span class='st_twitter_hcount'></span>
<span class='st_fblike_hcount'></span>

But I am trying to dynamically generate these buttons using:

stWidget.addEntry({
"service" : shareService,
"element" : document.getElementById(shareElemendID),
"url" : shareURL,
"title" : shareTitle,
"type" : shareType,
"onhover" : false
});

(Note: my shareType var is dynamically generated with javascript. You can see the javascript by viewing the test page's source.)

I can use "chicklet" as the hard value for "type" but this does not render the hcount buttons correctly. So I have a bit of js that determines whether to use "chicklet" or "hcount", but even hcount has funny results. (See http://ignitepixels.com/test/shareThisTest.html under header "Dynamic ShareThis Buttons").

Anyone have any clue what type should I be using for the hcount buttons I am using in my javascript?

Thanks!

War es hilfreich?

Lösung

For future users, here's the answer I received from a ShareThis Support Agent (http://support.sharethis.com/customer/portal/questions/862200-proper-share-type-for-st-twitter-hcount-and-st-fblike-hcount-dynamic-specification-through-js-#sthash.F82qZiuZ.dpbs):

You are getting malformed buttons because you are using an incorrect "service" name. You cannot use service names like these - "st_twitter_hcount"

Please use service names as - "twitter","facebook" and then you can specify the button type in "type" as "hcount" or "vcount".

Below is an example on how to achieve this using the code that you have implemented.

shareServices : ['twitter', 'facebook', 'linkedin', 'googleplus', 'email', 'reddit', 'st_twitter', 'st_fblike','st_wordpress','st_linkedin']

shareType = ( shareService.match(/^st_/) ) ? 'hcount' : 'chicklet' ;
if( shareService.match(/^st_/) )
{
    shareService=shareService.substring(3);
};
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top