This is a wrapper for the Yo API service for use in a Meteor project.
To install in a new project:
meteor add paulm:yo-meteor
This package uses the http
Meteor package, so it will automatically add that in for you.
Define the Yo API on the server side of the Meteor app:
if (Meteor.isServer) {
var yo = new yoAPI('YOUR_YO_API_KEY');
}
Now you can send a Yo to everyone with one line on the server side:
yo.all()
Attach a link to that Yo like this:
yo.all('http://meteor.com')
Or send a Yo to one person:
yo.one('PAULM')
What a link:
yo.one('PAULM', 'http://atmospherejs.com')
Or get your Yo subscribers count:
yo.subscribers()
To send a Yo from an action on the client side, set up a Meteor.method
on the server side of the Meteor app:
Meteor.methods({
yoAll: function(){
return yo.all()
},
yoOne: function(user){
return yo.one(user)
},
yoSubscribers: function(){
return yo.subscribers()
}
});
Then call the Yo API method from someplace on the client side:
Meteor.call('yoAll');
or
Meteor.call('yoOne', username, function(err, result){
if(!err){
console.log(result)
}
});
or
Meteor.call('yoSubscribers', function(err, result){
if(!err){
alert(result.data.result) // This is where the count is in the result.
}
});
For more information on the Yo API, check out this post on Medium.
License: MIT Author: Paul Molluzzo ©2014