Tweet Button & HashTags... is it possible?


#1

Hello all!

I’ve included a “Share on Twitter” button on my website, and I’m trying to include a small blurb that shows up in the share box by default - the blurb uses HashTags but they don’t seem to be working correctly. This is what I’ve written for the share box:

“Share @MyApp with the world! Coming soon to #iPhone and #Android

When you hit the “Share on Twitter” button, what happens is the blurb only shows “Share @MyApp with the world! Coming soon to” and omits anything after #iPhone and #Android.

Any idea what could be causing this and how to remedy it?

Your help would be greatly appreciate! =)


#2

You probably need to html encode your hash: # instead of #


#3

Ponra - Thanks for your suggestion but I tried the character code for the hashtag and it still didn’t work =(

Any other ideas?


#4

I found an example of CNN using a HashTag on their share button, so it is definitely possible.

Take a look, the twitter share button is near the top right:

When I copy the link address I get: https://twitter.com/intent/tweet?url=http%3A%2F%2Fwww.cnn.com%2F2011%2FTRAVEL%2F07%2F20%2Ftsa.body.scans%2Findex.html&text=New%20technology%20will%20enhance%20privacy%20on%20body%20scanners%2C%20TSA%20says&hashtags=cnn

Notice how there is an & before hashtags=cnn, not sure how that works exactly but I thought i’d share it here just in case it sparks an idea/solution…


#5

Anyone?


#6

Hi Sunny.

There are two parts to this. CNN are using the actual hashtags argument for the Tweet Intent to append hashtags to the text. This is a comma-separated list of tags. So, for example:

http://twitter.com/intent/tweet?url=http://example.com&text=Hello+world!&hashtags=foo,bar,baz

That invokes the intent with just the text ‘Hello world!’ highlighted, followed by #foo #bar #baz, followed by the shortened URL.

For your example though, where you want the hashtags embedded in your text, you will need to encode the hashes. Hashes are special characters in the URL (they identify document fragments) so they, and anything following, does not get sent the server.

@Ponra was close with the suggestion to HTML encode the #, but you need to URLEncode it, so use %23. Like this:

http://twitter.com/intent/tweet?url=http://example.com&text=Share+@MyApp+with+the+world!+Coming+soon+to+%23iPhone+and+%23Android

Hope that helps,

@benward, Twitter Platform Developer


#7

@BenWard Thank you so much for your answer. That was exactly what I was looking for and I thought it was impossible. I really appreciate your help!! =D


#8

Your example code and the CNN example code work.

Putting the ‘hashtags’ attribute into the tweet share interface or embedding the URLEncode hashtags in the ‘text’ attribute does not work.

So, if you want to share a “Tweet” button with a counter, it appears to not be doable at this time.

Or am I missing something?


#9

Not sure if this is where I would ask this question but, here is in hopes that someone may know the answer. Just recently my website url’s are adding what looks like a hashtag to the end of all of my pages. Looks like this:

http://www.grabscents.com/browse-products/scentsy-package-deals#.TuKOr7Ik5ts

Everything from the # and on is not suppose to be there. Any clue as to what it is and where it came from??


#10

Thanks @BenWard it was exactly what I was searching!


#11

The HTML one get from [Twitter buttons] ( https://twitter.com/about/resources/buttons#hashtag ) seems to be wrong:

Tweet #test


#12

Hi @webjay – thanks for pointing out that the configurator is broken in that instance. Asking the team to fix that.


#13

Thank you so much for this!


#14

Hi guys,
I need a bit of help please. Here’s what I am trying to do:

 - Site CoolPile.com (Wordpress Based)
 - I am trying to create a Tweet This button and include the post Categories and Tags as Hashtags in the Tweet message ... For example, let say that post X has the tags A1, A2 an A3 and it is in the B1 category. The tweet message should look like: "[Page Title] - [Page URL] - via @[Twitter Username] - #B1 #A1 #A2 #A3.

Does anyone know a way to achieve this? Does anyone know a WP plugin that does this? If I need to hardcode it, how should I go about it - can anyone help with a piece of code?

Thanks in advance.


#15

Hi guys,

Anyone to give a hand to a poor soul who’s parents pushed him to Basketball rather than programming??? :slight_smile:


#16

Hi,

I have the same problem, I was able to set "[Page Title] - [Page URL] - via @[Twitter Username]* but I can not even enter the hashtag #tag1 #tag2 #tag3

Thanks


#17

You can use %23 to replace # sign

http://Teqy.co


#18

Thank you @benward! This was very helpful.


#19

@benward, any idea how to do this if the hashtag is in the middle of the text? For example if I wanted the tweet to read 'Hello #world - how are you?'
Thanks.


#20

did you manage to get this done @CoolPileCom? i am trying to build a list of hashtags programmatically and I can use some help :slight_smile: thanks in advance