Question

I am using this TWEET BUTTON code in my web (inserted from GWT):

<a href=\"https://twitter.com/share\" class=\"twitter-share-button\"
data-url=\"http://www.example.com/#!v;id="+diagramId+"\" 
data-text=\""+diagramTitle+"\" data-via=\"example\">Tweet</a>

When I click on it, the result is correct. This tweet is posted:

MYTITLE http://www.example.com/#!v;id=r5sWfujKlSua via @example

However, what is wrong is the data-count that the button displays. I would say it is counting the total amount of tweet of http://www.example.com instead of http://www.example.com/#!v;id=r5sWfujKlSua (which should be 0 and its 79).

Any ideas? Thanks

Was it helpful?

Solution

You need to URL encode the # symbol with %23. This is similar to adding hash tags to the tweeted message, as discussed in this discussion on dev.twitter.com; see the reply by Ben Ward.

Only using HTML and javascript (no GWT), the following counts example.com, since the # tag is not encoded in the data-counturl property:

<a href="https://twitter.com/share" class="twitter-share-button"
    data-url="http://www.example.com/#!v;id=0" 
    data-counturl="http://www.example.com/#!v;id=0" data-via="example">Tweet</a>

When I replace # with %23 in the data-counturl property, I get a number of 0:

<a href="https://twitter.com/share" class="twitter-share-button" 
    data-url="http://www.example.com/#!v;id=0" 
    data-counturl="http://www.exmaple.com/%23!v;id=0 data-via="example">Tweet</a>
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top