Twitter--Tweet from in-game

Is it possible to allow a user to tweet from within game? I’ve got it loading my Twitter account, but it’s not auto-filling the text.
let btn = this.add.image(100, 100, ‘button’).setScale(0.5).setInteractive();

    btn.on('pointerdown', function(){

        let url = 'https://twitter.com/home?status=';

        let text = "I'm testing a tweet from the game.";

        url += '?text=' + text;

        window.open(url, '_blank');

    });

your url is turning into

https://twitter.com/home?status=?text=I’m testing a tweet from the game.

which I dont think is what you want

Instead the APi has changed to http://twitter.com/intent/tweet?text=

so make your code

btn.on('pointerdown', function(){

    let url = 'http://twitter.com/intent/tweet?text=';

    let text = "I'm testing a tweet from the game.";

    url +=  text;

    window.open(url, '_blank');

});
2 Likes