livejournal
Advanced tools
Comparing version 0.0.8 to 0.1.0
79
index.js
@@ -1,75 +0,14 @@ | ||
var request = require('request'); | ||
'use strict'; | ||
var RPC = require('./rpc'); | ||
module.exports = { | ||
utils: { | ||
parseLink: require('./lib/utils/parseLink'), | ||
getFacebookStats: require('./lib/utils/getFacebookStats') | ||
}, | ||
var API = require('./api'); | ||
API: require('./lib/api'), | ||
var rxLink = [ | ||
/([0-9a-zA-Z-_]+)\.livejournal\.com\/([0-9]+)\.html/, | ||
/m\.livejournal\.com\/read\/[a-z]+\/([0-9a-zA-Z_-]+)\/(\d+)/, | ||
/users\.livejournal\.com\/([0-9a-zA-Z-_]+)\/([0-9]+).html/ | ||
]; | ||
xmlrpc: require('./lib/xmlrpc'), | ||
function _groupBy(arr, amount) { | ||
var result = [], offset = 0; | ||
do { | ||
result.push(arr.slice(offset, offset + amount)); | ||
offset += amount; | ||
} while (offset < arr.length); | ||
return result; | ||
} | ||
function getFBStats(urls, callback) { | ||
var groups = _groupBy(urls, 10), | ||
result = {}, | ||
done = 0; | ||
groups.forEach(function(group) { | ||
request({ | ||
url: 'http://graph.facebook.com/?ids=' + group.join(','), | ||
json: true | ||
}, function(err, res, body) { | ||
if (!err && res.statusCode == 200) { | ||
for (var key in body) { | ||
result[key] = body[key].shares || 0; | ||
} | ||
done++; | ||
if (done >= groups.length) { | ||
callback(null, result); | ||
} | ||
} else { | ||
callback(err); | ||
} | ||
}); | ||
}); | ||
} | ||
function parseLink(url) { | ||
if (!url) { | ||
return null; | ||
} | ||
for (var i = 0, match; i < rxLink.length; i++) { | ||
match = url.match(rxLink[i]); | ||
if (match && match.length === 3) { | ||
return { journal: match[1], postId: match[2] }; | ||
} | ||
} | ||
return null; | ||
} | ||
module.exports = { | ||
getFBStats: getFBStats, | ||
parseLink: parseLink, | ||
RPC: RPC, | ||
API: API | ||
jsonrpc: require('./lib/jsonrpc') | ||
}; |
{ | ||
"name": "livejournal", | ||
"version": "0.0.8", | ||
"description": "LiveJournal XMLRPC", | ||
"keywords": ["livejournal", "blog"], | ||
"version": "0.1.0", | ||
"description": "LiveJournal API", | ||
"keywords": [ | ||
"livejournal", | ||
"blog", | ||
"social", | ||
"xmlrpc", | ||
"jsonrpc" | ||
], | ||
"scripts": { | ||
"test": "jasmine" | ||
}, | ||
"author": "Artem Tyurin <artem.tyurin@gmail.com>", | ||
@@ -12,6 +21,9 @@ "repository": { | ||
"dependencies": { | ||
"xmlrpc": "git://github.com/agentcooper/node-xmlrpc.git", | ||
"request": ">=2.25" | ||
"superagent": "^1.2.0", | ||
"xmlrpc": "^1.3.1" | ||
}, | ||
"main": "index" | ||
"main": "index", | ||
"devDependencies": { | ||
"jasmine": "^2.3.1" | ||
} | ||
} |
@@ -1,6 +0,8 @@ | ||
## LiveJournal XMLRPC for Node | ||
## LiveJournal API | ||
[![Build Status](https://travis-ci.org/agentcooper/node-livejournal.svg?branch=master)](https://travis-ci.org/agentcooper/node-livejournal) | ||
`npm install livejournal` | ||
### Docs | ||
This package provides access to both XMLRPC and JSONRPC APIs for LiveJournal. | ||
@@ -12,11 +14,7 @@ ## XMLRPC | ||
## Other | ||
Examples | ||
* http://www.livejournal.com/developer/ | ||
* http://lj-dev.livejournal.com/ | ||
### Example | ||
```javascript | ||
LiveJournal.RPC.getevents({ | ||
// get posts inside the journal using XMLRPC | ||
LiveJournal.xmlrpc.getevents({ | ||
journal: 'brad', | ||
@@ -32,3 +30,4 @@ auth_method: 'noauth', | ||
```javascript | ||
LiveJournal.RPC.getevents({ | ||
// get post content using XMLRPC | ||
LiveJournal.xmlrpc.getevents({ | ||
journal: 'brad', | ||
@@ -43,7 +42,76 @@ auth_method: 'noauth', | ||
## JSONRPC | ||
There is no official public description of LiveJournal JSON RPC methods, but you can check `Site.rpc.public` on `http://livejournal.com`. Because the data is stored on CDN, you can access the data from anywhere. | ||
Those are current ones (badly documented, contributions are welcome): | ||
##### `discovery.author_posts` | ||
##### `comment.get_thread` | ||
Get comments thread | ||
``` | ||
Params: | ||
journal -- Journal username | ||
itemid -- Post id | ||
``` | ||
##### `latest.get_entries` | ||
Get latest posts | ||
``` | ||
Params: | ||
first_timepost | ||
``` | ||
##### `browse.get_posts` | ||
##### `gifts.get_gifts_categories` | ||
##### `gifts.get_all_gifts` | ||
##### `homepage.get_categories` | ||
##### `discovery.suggest` | ||
##### `sitemessage.get_message` | ||
##### `discovery.get_categories` | ||
##### `browse.get_categories` | ||
##### `writers_block.get_list` | ||
##### `discovery.today` | ||
##### `discovery.get_feed` | ||
##### `discovery.get_item` | ||
##### `homepage.get_rating` | ||
##### `browse.get_communities` | ||
Examples | ||
```js | ||
// get latest posts using JSONRPC | ||
LiveJournal.jsonrpc.request('latest.get_entries', { | ||
first_timepost: 1435262400 | ||
}, function(err, res) { | ||
console.log(res.body.result.params.recent); | ||
}); | ||
``` | ||
```js | ||
// get comments using JSONRPC | ||
LiveJournal.jsonrpc.request('comment.get_thread', { | ||
journal: 'tema', | ||
itemid: '1987717' | ||
}, function(err, res) { | ||
console.log(res.body.result.comments) | ||
}); | ||
``` | ||
You can access method list using `LiveJournal.jsonrpc.methods`. | ||
## API | ||
LiveJournal.API is wrapper around some resources provided at http://www.livejournal.com/bots/ | ||
## Other docs and resources | ||
* http://www.livejournal.com/developer/ | ||
* http://lj-dev.livejournal.com/ | ||
* http://www.livejournal.com/bots/ | ||
## Tests | ||
``` | ||
npm install jasmine-node -g | ||
jasmine-node spec/ | ||
npm install jasmine -g | ||
npm test | ||
``` |
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Git dependency
Supply chain riskContains a dependency which resolves to a remote git URL. Dependencies fetched from git URLs are not immutable can be used to inject untrusted code or reduce the likelihood of a reproducible install.
Found 1 instance in 1 package
12361
15
317
115
0
1
1
+ Addedsuperagent@^1.2.0
+ Addedasync@1.5.2(transitive)
+ Addedcomponent-emitter@1.2.1(transitive)
+ Addedcookiejar@2.0.6(transitive)
+ Addedcore-util-is@1.0.3(transitive)
+ Addeddebug@2.6.9(transitive)
+ Addedextend@3.0.0(transitive)
+ Addedform-data@1.0.0-rc3(transitive)
+ Addedformidable@1.0.17(transitive)
+ Addedinherits@2.0.4(transitive)
+ Addedisarray@0.0.1(transitive)
+ Addedmethods@1.1.2(transitive)
+ Addedmime@1.3.4(transitive)
+ Addedms@2.0.0(transitive)
+ Addedqs@2.3.3(transitive)
+ Addedreadable-stream@1.0.27-1(transitive)
+ Addedreduce-component@1.0.1(transitive)
+ Addedsax@1.2.4(transitive)
+ Addedstring_decoder@0.10.31(transitive)
+ Addedsuperagent@1.8.5(transitive)
+ Addedxmlbuilder@8.2.2(transitive)
+ Addedxmlrpc@1.3.2(transitive)
- Removedrequest@>=2.25
- Removedajv@6.12.6(transitive)
- Removedasn1@0.2.6(transitive)
- Removedassert-plus@1.0.0(transitive)
- Removedasynckit@0.4.0(transitive)
- Removedaws-sign2@0.7.0(transitive)
- Removedaws4@1.13.2(transitive)
- Removedbcrypt-pbkdf@1.0.2(transitive)
- Removedcaseless@0.12.0(transitive)
- Removedcore-util-is@1.0.2(transitive)
- Removeddashdash@1.14.1(transitive)
- Removedecc-jsbn@0.1.2(transitive)
- Removedextend@3.0.2(transitive)
- Removedextsprintf@1.3.0(transitive)
- Removedfast-deep-equal@3.1.3(transitive)
- Removedfast-json-stable-stringify@2.1.0(transitive)
- Removedforever-agent@0.6.1(transitive)
- Removedform-data@2.3.3(transitive)
- Removedgetpass@0.1.7(transitive)
- Removedhar-schema@2.0.0(transitive)
- Removedhar-validator@5.1.5(transitive)
- Removedhttp-signature@1.2.0(transitive)
- Removedis-typedarray@1.0.0(transitive)
- Removedisstream@0.1.2(transitive)
- Removedjsbn@0.1.1(transitive)
- Removedjson-schema@0.4.0(transitive)
- Removedjson-schema-traverse@0.4.1(transitive)
- Removedjson-stringify-safe@5.0.1(transitive)
- Removedjsprim@1.4.2(transitive)
- Removedoauth-sign@0.9.0(transitive)
- Removedperformance-now@2.1.0(transitive)
- Removedpsl@1.9.0(transitive)
- Removedpunycode@2.3.1(transitive)
- Removedqs@6.5.3(transitive)
- Removedrequest@2.88.2(transitive)
- Removedsafe-buffer@5.2.1(transitive)
- Removedsafer-buffer@2.1.2(transitive)
- Removedsshpk@1.18.0(transitive)
- Removedtough-cookie@2.5.0(transitive)
- Removedtunnel-agent@0.6.0(transitive)
- Removedtweetnacl@0.14.5(transitive)
- Removeduri-js@4.4.1(transitive)
- Removeduuid@3.4.0(transitive)
- Removedverror@1.10.0(transitive)
Updatedxmlrpc@^1.3.1