I am attempting to use the POST statuses/update Twitter API call. I'm new to this so please bear with me :). As outlined in this doc I've been trying to set up headers to use application only authentication.
What I have tried so far is as follows:
$(".tweet-later").on("click", function(event){
$.ajax({
url: "https://api.twitter.com/1.1/statuses/update.json",
data: { status: "Testing"},
type: "POST",
dataType: 'json',
beforeSend: function(xhr){
xhr.setRequestHeader('Authorization', 'Rm5DVHpIc2M2ejRpeDRQRDRdfdsjprbjB5TENzeEZQNnhza2NFMzB6dnJMbnI2aENlRUZSczdOZUtWZUhaREhXSFVCY3dQWA==');
xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded;charset=UTF-8');
},
success: function(data) { alert('Tweeted!'); },
error:function(exception){alert('Exeption:'+exception);}
});
});
I keep receiving an error: "Authentication Failed".All help is very much appreciated.
Thank you very much in advance.
What you're trying to do is impossible.
As it says in the documentation :
When issuing requests using application-only auth, there is no concept of a “current user.” Therefore, endpoints such as POST statuses / update will not function with application-only auth. See using OAuth for more information for issuing requests on behalf of a user.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.