Stuck on the twitter part [Solved]

If anybody could help with my problem.

I’ve used an api to get the quotes from instead of using an array to do them myself. This is working but…

I cannot seem to find a way to get the quotes onto a tweet message, it’s just loading what’s in my title tags. Seems this is a default action from twitter if I haven’t set it something to add (which is what I’ve been trying to do).

I’m pretty lost here, just going round and round in circles, looking at others have done it anf googling etc. I could just scrap this and build an array but I really want to try and get this to work.

Can anybody give me any hints or suggestions, I’d really appreciate it.

Here is my code


1 Like

Ditching the API wouldn’t help you. You’re really close, but I think the Twitter API you’re using is meant to share an entire page and it’s conflicting with the very correct JavaScript code you have written to share the quote. I got it to work by changing the following lines

<a class="twitter-share-button" href="" target "_blank" id="tweet" data-size="large" data-show-count="false">Tweet</a>
<script async src="//" charset="utf-8"></script>

to be

<div class="twitter-share-button btn btn-primary">Tweet</div> 

You could add the absurdly fabulous FontAwesome to get a nice Twitter icon in your button if you’ like.

Thank you so much!!! It works…phew!

Now its functional, I can work on making it look better!


1 Like