How to send tweet to twitter with jquery inside my site
There is MANY API and script and plugin out there to get feed, hash tag and tweet from twitter. I like to SEND tweet TO twitter from my site with jquery
something like
$('#somebutton').click( function (){
var text='some intelligent things to say';
#.twitit(text);
})
it's it something possible ?
now i use :
<a href="https://twitter.com/share" class="twitter-share-button" data-co开发者_开发百科unt="vertical">Tweet it</a></div>
but that take the title of the page to send it to twitter.. not really what i want !
What's wrong with:
<a href="https://twitter.com/share" class="twitter-share-button" data-text="Something other than page title" data-count="vertical">Tweet it</a></div>
You can even set it dynamically via:
$('.twitter-share-button').attr('data-text', 'Some text to tweet');
UPDATE: If you're just trying to use your own Twitter button, you can simply use web intents, Twitter's fancy way of saying "regular old URLs". See: https://dev.twitter.com/docs/intents
https://twitter.com/intent/tweet?url=[your URL]&text=[some text to tweet]
Since it's part of a URL, make sure you urlencode all the parameters.
here is some sample code i have found... I still have the big ugly twitter button !
<script>
$(document).ready(function(){
$('a[data-text]').each(function(){
$(this).attr('data-text', "This works!");
});
$.getScript('http://platform.twitter.com/widgets.js');
});
</script>
<a href="http://twitter.com/share"
class="twitter-share-button"
data-text="This is what we want to change dynamically"
data-count="none" data-via="chris_camps">Tweet</a>
<!-- moved to the js above <script type="text/javascript"
src="http://platform.twitter.com/widgets.js"></script> -->
精彩评论