Skip to content

Instantly share code, notes, and snippets.

@stephenjfox
Created January 22, 2017 09:46
Show Gist options
  • Save stephenjfox/8ef48cc2662ba046784cfe35099b440a to your computer and use it in GitHub Desktop.
Save stephenjfox/8ef48cc2662ba046784cfe35099b440a to your computer and use it in GitHub Desktop.
Create and send a tweet for a Random Quote Machine
/* Read the text from our elements and compose a tweet POST request string*/
const formTweetUrl = () => {
// Element initializations elided
const text = mainQuoteElement.innerHTML;
const author = authorElement.innerHTML;
const tweetUrl = `https://twitter.com/share?text="${text}" - ${author}&url=http://codepen.io/stevemasta34/full/GrWmjJ/`;
return tweetUrl;
};
const sendTweet = () => {
console.log("Tweeting");
window.open(formTweetUrl()); // the money maker ;)
console.log("Tweeted");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment