[英]Setting headers in Twitter API POST
I am attempting to use the POST statuses/update Twitter API call. 我正在尝试使用POST状态/更新Twitter API调用。 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.
当使用仅应用程序身份验证发出请求时,没有“当前用户”的概念。因此,诸如POST状态/更新之类的端点将不适用于仅应用程序身份验证。 See using OAuth for more information for issuing requests on behalf of a user.
请参阅使用OAuth了解有关代表用户发出请求的更多信息。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.