New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

easy-twitter

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

easy-twitter - npm Package Compare versions

Comparing version 0.0.7 to 1.0.0

27

lib/Twitter.js

@@ -195,2 +195,5 @@ var twitter = require('twitter');

/**
* @deprecated : Since 0.0.7 : use getCounts() instead
*/
getFollowersCount(twitterName) {

@@ -216,4 +219,28 @@ var client = this.client;

}
/**
* A method which returns the follower count and the friend count of a twitter account
*/
getCounts(twitterName) {
var client = this.client;
return new Promise(function(resolve, reject) {
//_Delete the '@' from the name if it exists
if(twitterName.substr(0,1) === '@') {
//console.log('Delete @ from the name ...');
twitterName = twitterName.substr(1);
}
client.get('users/show', {screen_name : twitterName}, function(err, infos, res) {
if(err) {
reject({error: err, user: twitterName});
return -1;
}
resolve({followersCount : infos.followers_count, friendsCount: infos.friends_count, user: twitterName});
});
});
}
}
module.exports = Twitter;

6

package.json
{
"name": "easy-twitter",
"version": "0.0.7",
"version": "1.0.0",
"description": "A simple twitter module",

@@ -8,7 +8,7 @@ "main": "index.js",

"scripts": {
"test": "test/test.js"
"test": "./test/test.js"
},
"repository": {
"type": "git",
"url": "https://github.com/Pandazaur/node-twitter-es6.git"
"url": "https://github.com/Pandazaur/easy-twitter.git"
},

@@ -15,0 +15,0 @@ "author": "Pandazaur",

@@ -75,4 +75,4 @@ # easy-twitter

//_Both the variables are correct
var twitterAccount = 'iAmAlphaZz'
var secondTwitterAccount = '@iAmAlphaZz'
var twitterAccount = 'iAmAlphaZz';
var secondTwitterAccount = '@iAmAlphaZz';

@@ -93,4 +93,4 @@ twitter.follow(twitterAccount)

//_Both the variables are correct
var twitterAccount = 'iAmAlphaZz'
var secondTwitterAccount = '@iAmAlphaZz'
var twitterAccount = 'iAmAlphaZz';
var secondTwitterAccount = '@iAmAlphaZz';

@@ -105,1 +105,63 @@ twitter.unfollow(twitterAccount)

```
#### Get the followers of a twitter account
Get the `count` (max: 200) followers list of `twitterAccount`
```javascript
var twitterAccount = 'iAmAlphaZz';
var count = 12;
twitter.getFollowersList(twitterAccount, count)
.then(function(data) {
// data.followers : Array of the followers name ( 12 followers because count = 12)
// data.fullInfos : More infos below
// data.user : 'iAmAlphaZz' in this case
})
.catch(function(err) {
console.log(err.error);
});
```
The method `getFollowersList()` return three datas:
- `followers`: An array with the account names of the followers
- `fullInfos`: A JSON Object which contains a lot of informations. Here is a link showing the differents informations returned in this object ( look the 'Example Result' : https://dev.twitter.com/rest/reference/get/followers/list)
- `user`: Is the user name of the twitter account you entered in parameter to the method.
#### Get the friends of a twitter account
Get the `count` (max: 200)people from the followers list of `twitterAccount`.
Actually, it returns only the lasts. The `page` parameter will able to choose more precisely.
```javascript
var twitterAccount = 'iAmAlphaZz';
var count = 50;
twitter.getFollowersList(twitterAccount, count, page)
.then(function(data) {
// data.friends : Array of the friends name ( 50 followers because count = 50)
// data.fullInfos : More infos below
// data.user : 'iAmAlphaZz' in this case
})
.catch(function(err) {
console.log(err.error);
});
```
The method `getFollowersList()` return three datas:
- `followers`: An array with the account names of the followers
- `fullInfos`: A JSON Object which contains a lot of informations. Here is a link showing the differents informations returned in this object ( look the 'Example Result' : https://dev.twitter.com/rest/reference/get/friends/list)
- `user`: Is the user name of the twitter account you entered in parameter to the method.
- `page`: Is not yet implemented...
#### Get the followers count & friends count
```javascript
twitter.getCounts('iAmAlphaZz')
.then(function(data) {
// data.user : In this case 'iAmAlphaZz'
// data.followersCount : Count of people following the account in parameter
// data.friendsCount : count of people the twitter account in parameter is following
})
.catch(function(err) {
console.log(err.error);
})
```
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc