更新推特状态
我使用了 Twitter 的 Anywhere 和其中的 connectButton
来连接我的带有页面和帐户的应用程序。现在如何在没有文本框的情况下更新我的状态?只需发送一些需要新状态字符串的请求。我发现 this 官方页面:
Example Requests
POST https://api.twitter.com/1/statuses/update.json
status=Maybe%20he%27ll%20finally%20find%20his%20keys.%20%23peterfalk&trim_user=true&include_entities=true
所以我写道:
$.post('https://api.twitter.com/1/statuses/update.json', {status: 'test'}, function(res) {
console.log(res);
});
它返回401 身份验证错误。那么,有什么想法吗?
I used Anywhere from twitter and connectButton
from it which connected my app with page and account. How can I update my status now without textbox? Just send some request with need new status string. I found this oficial page:
Example Requests
POST https://api.twitter.com/1/statuses/update.json
status=Maybe%20he%27ll%20finally%20find%20his%20keys.%20%23peterfalk&trim_user=true&include_entities=true
So I wrote:
$.post('https://api.twitter.com/1/statuses/update.json', {status: 'test'}, function(res) {
console.log(res);
});
And it returns 401 auth error. So, any ideas?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我认为您将 Twitter REST API 与 @Anywhere 库混淆了。仅当用户通过 oAuth 进行身份验证并且应用程序提供了HTTP 请求中的 oAuth 密钥。 @Anywhere 库是另一个库,它可以让使用 Javascript 库的 Web 开发人员更轻松地访问 Twitter。
您收到 401 身份验证错误,因为您没有向 API 请求提供 oAuth 标头,这意味着用户未通过 API 身份验证。这独立于@Anywhere(连接按钮)的身份验证方案。
您要么必须重写代码,以便首先通过 oAuth 对用户进行身份验证,然后使用 REST 调用来发布推文,要么必须使用 @Anywhere 库的功能为用户提供推文框。
I think you are mixing up the Twitter REST API with the @Anywhere library. The REST API can only be used when an user is authenticated with oAuth and the application provides an oAuth key in the HTTP request. The @Anywhere library is another library that provides easier access to Twitter for web developers using a Javascript library.
You receive a 401 authentication error because you haven't supplied oAuth headers with the API request, which means that an user is not authenticated for the API. This is independent from the authentication scheme for @Anywhere (the connect button).
You either have to rewrite your code so that you first authenticate an user via oAuth and then use a REST call to post a tweet, or you have to use the features of the @Anywhere library to provide users a tweet box.