hamed
hamed

Reputation: 61

Post tweet in twitter directly from my website using javascript

My website is allow user to tweet something to their timeline in twitter. When they click on tweet button, twitter box platform will popup and user can write or edit something before tweet; but I don't want this way, I want is when they click on tweet button it will tweet to their timeline automatically (no need to call twitter box platform). Is it possible?

Upvotes: 3

Views: 9843

Answers (3)

benedict
benedict

Reputation: 1

const windowReference=window.location.href;
const hrefEl="https://twitter.com/intent/tweet?url=" + windowReference + "&text=" + encodeURIComponent(textToTweet);
tweetButton.setAttribute('href',hrefEl)

Upvotes: 0

VirgilCane
VirgilCane

Reputation: 49

Short answer: no

When using the Twitter API, anything that you want to do that involves a user's account (post tweets, retweet, favorite, etc. ) will require permission from the user. This permission is given in the form of a user's unique access key and secret.

In order to obtain a user's key & secret you will need to authenticate the user using a Twitter sign in. This process will take the user to Twitter's sign in page. Once they have successfully signed in they will be redirected back to your app.

For further reading, please see: https://developer.twitter.com/en/docs/accounts-and-users/subscribe-account-activity/guides/authenticating-users

Upvotes: 1

Clément Laffitte
Clément Laffitte

Reputation: 106

Here is the twitter's documentation : https://dev.twitter.com/web/javascript

Upvotes: 3

Related Questions