wykop-es6

Instalacja
npm install wykop-es6-2
Dokumentacja Wykop API
Przykładowe użycie (promises)
var Wykop = require('wykop-es6');
var wykop = new Wykop('appkey', 'secretkey');
var user = new Wykop('appkey', 'secretkey');
user.login('accountkey')
.then(function(res) {
console.log(res);
return user.request('Entries', 'Add', {post: {body: "test", embed: "http://plik.jpg"}});
})
.then(function(res) {
console.log(res);
return wykop.request('Stream', 'Index', {api: {page: 1}});
})
.then(function(res) {
console.log(res);
var firstEntryId = res[0].id;
return user.request('Entries', 'Vote', { params: ['entry', firstEntryId] });
})
.then(function(res) {
console.log(res);
})
.catch(function(err) {
console.log(err);
});
Przykładowe użycie (callback)
user.login(accountkey, function(error, res) {
if (error) throw error;
console.log(res);
user.request('Entries', 'Add', {
post: {
body: "test",
embed: "http://plik.jpg"
}
}, function(error, res) {
if (error) throw error;
console.log(res);
});
});
Opcje
var options = {
output: 'clear',
format: 'jsonp',
timeout: '30000',
useragent: 'WypokAgent',
ssl: false
};
var wykop = new Wykop(<appkey>, <secretkey>, options);
Parametry metody .request
var reqOptions = {
params: [ ],
api: { },
post: { }
};
wykop.request('rtype', 'rmethod', reqOptions);