The button shows up correctly, but when pressed, it brings up a Tweet dialog box with “Quote Machine” (the title to my index.html) instead of the quote and author.
Uhm…actually i did never see that ‘createShareButton’, it’s cool! Anyway, reading the docs:
twttr.widgets.createShareButton(
'/',
document.getElementById('new-button'),
{
count: 'none',
text: 'Sharing a URL using the Tweet Button'
}).then(function (el) { // <--- I can't see this in your code
console.log("Button created.")
});
Since every create function return a promise, is like you’re missing the callback part if i’m not wrong ( which it could be at all )
Ah whoops, so that’s old code, just forgot to push my newer stuff. That code actually worked, but since it was under my “getQuote” function, it would create a new Twitter button every time you press “Get Quote” and just append it to the page.
Ok, so…i downloaded the code and tried to get it to work…unfortunately, i wasn’t able to get rid of the “twttr.widgets is not defined”: looking here and there i found this ( maybe) clarification statement:
To use Twitter counter widget and other Twitter related widgets, you need OAuth access keys.
from themeFactory: how to generate twitter stuff.
It’s a company that builds wordpress sites, i don’t know why it doesn’t appear the link of the official twitter documentation while googling…anyway, as far as i can see the functionality you’re triyng to use is restricted to the api registered user ^^ Obviously you can go further and explore the twitter API’s world, but for this challenge is not required at all.
In your code i saw a shareTweet function: that’s a more usual way to achieve the result (you can collect more information here: twitter documentation - tweet button).
This is the string to use, i just added what was missing var twtLink = 'https://twitter.com/intent/tweet?text=' + encodeURIComponent(response.quote + " " + response.author);
Bind this function to an event listener and you’re done ^^
P.S:
I like your random quote app! Minimal style, minimal code and every functionality it needs, in my opinion gj!
I had the same problem of the new Tweet containing the page title instead of quote. I found it far easier to remove all the stuff that was provided by the Twitter Dev site. Just create your own button, style as you please and populate the url attribute from your JS (Just as the above reply finishes with).