我正试图建立一个应用程序与流星,涉及用户与twitter, facebook,或谷歌+登录,然后张贴到这些帐户从应用程序内。
首先我试着让twitter工作。我的推特登录正常,允许我代表他们发推特,但我怎么发推特呢?
我想我需要这个:https://dev.twitter.com/docs/api/1.1/post/statuses/update但我不知道如何认证与流星。
这里有什么例子可以帮助我吗?或教程吗?
你需要一个API来帮助你一点,除非你想用REST与Meteor.http
手动完成它。我建议你买陨石:https://github.com/oortcloud/meteorite
通过npm install -g meteorite
像节点模块一样安装
Meteorite是meteor的包装器,允许您使用http://atmosphere.meteor.com
上的社区包。你可以使用的twitter包是twitter-api
通过mrt add twitter-api
安装:https://github.com/Sewdn/meteor-twitter-api
一旦使用服务器api添加,您可以添加一个推文:
服务器JS
var twitter = new Twitter();
Meteor.methods({
postTweet: function (text) {
if(Meteor.user())
twitter.postTweet(text),
return true;
}
});
客户机JS //Use this in your click handler where you want to post a tweet:
Meteor.call("postTweet", "This is Twweeeeeetttt!", function(err,result) {
if(!err) {
alert("Tweet posted");
}
});
api负责用户的oauth令牌,所以您不必担心太多