Closed elius1234 closed 8 years ago
/message is not a valid endpoint in the twitter API. I'm not sure where you found the documentation for '/message' but it seems this endpoint does not exists. If I'm right, it's for this very reason you're receiving HTML (which is their 404 page).
All availble endpoints for the Twitter API are described here: https://dev.twitter.com/rest/public
so basically, to post a tweet in the Twitter Timeline (https://dev.twitter.com/rest/reference/post/statuses/update), it would be:
result.post({
url: '/1.1/statuses/update.json',
data: {
status: 'Hello World'
}
}).done(function(data) {
//todo when the tweet is posted
})
To post a direct message (https://dev.twitter.com/rest/reference/post/direct_messages/new), it would be:
result.post({
url: '/1.1/direct_messages/new.json',
data: {
user_id: 93,
text: 'Hello Mr. 93!'
}
}).done(function(data) {
//todo when direct message is posted
})
To get the user_id of the authorized user (as the title mention), you can use me()
to get unified user informations (http://docs.oauth.io/?Javascript#user-data-api):
result.me().done(function(me) {
//todo with me.id
})
Thanks for the help thyb, it's working now.
Twitter sharing not working can anyone help? I am using the below code while executing the fail function is invoked and i am a html page in the response. OAuth.initialize("pv-0pAxUwYECGUf4vhkjhv8");
OAuth.popup('twitter', {cache: true}).done(function (result) {
.fail(function (e) { console.log('error: ' + e.message);
});