A
A
aarifkhamdi2019-07-09 14:26:45
JavaScript
aarifkhamdi, 2019-07-09 14:26:45

How to make sure that the retweet was made?

I want to add a "retweet" button to the site. How do I make sure the user actually retweeted and not just closed the page?

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <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"));

    twttr.ready(twttr => {

        twttr.events.bind(
            'retweet',
            function (event) {
                var retweetedTweetId = event;
                console.log(retweetedTweetId)
            }
        );
    })
    </script>
</head>
<body>
<a href="https://twitter.com/intent/retweet?tweet_id=463440424141459456">Retweet</a>
</body>
</html>

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
aarifkhamdi, 2019-07-28
@aarifkhamdi

I made a request for read permissions from the user account via OAuth.
There is no way to reliably check a retweet otherwise.

A
Andrew, 2019-07-09
@deepblack

1. Use the Twitter API
documentation. There is a method GET statuses/retweets/:id
Returns the last 100 retweets (it will suit you if there are no more than 100 retweets) of the tweet with the specified id.
2. View the latest tweet in the user's profile (you can also use the API)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question