I'm trying to implement twitter share in my React app. Judging by Twitter's SDK documentation, it seems like they really only show you how to include a twitter button (styled by them) which, when clicked, opens a dialog box to share your current url to twitter. The code looks something like this:
<a
className="twitter-share-button"
href="https://twitter.com/intent/tweet"
>
Tweet
</a>
<script>
window.twttr = (function(d, s, id) {
var js, fjs = d.getElementsByTagName(s)[0],
t = window.twttr || {};
if (d.getElementById(id)) return t;
js = d.createElement(s);
js.id = id;
js.src = "https://platform.twitter.com/widgets.js";
fjs.parentNode.insertBefore(js, fjs);
t._e = [];
t.ready = function(f) {
t._e.push(f);
};
return t;
}(document, "script", "twitter-wjs"))
</script>
I need to do 3 things:
- Dictate the url I would like to be sharing
- Customize the twitter share button to look completely different
- Occasionally in my program, I need to open the twitter share dialog box without clicking any button at all
Can anyone offer any help or point me in the right direction, because I've had a very hard time finding any helpful resources. Thanks