mirror of
https://github.com/ION606/linkedin-api.git
synced 2026-05-14 22:06:54 +00:00
added connections
This commit is contained in:
@@ -132,3 +132,4 @@ dist
|
||||
temp.*
|
||||
config.json
|
||||
cookie.txt
|
||||
temp/
|
||||
@@ -1,20 +0,0 @@
|
||||
# See https://docs.readthedocs.io/en/stable/config-file/v2.html for details
|
||||
|
||||
# Required
|
||||
version: 2
|
||||
|
||||
build:
|
||||
os: ubuntu-lts-latest
|
||||
tools:
|
||||
nodejs: "20"
|
||||
|
||||
# Build documentation in the "docs/" directory with Sphinx
|
||||
sphinx:
|
||||
configuration: docs/conf.py
|
||||
builder: "dirhtml"
|
||||
|
||||
|
||||
# Optionally build your docs in additional formats such as PDF and ePub
|
||||
formats:
|
||||
- pdf
|
||||
- epub
|
||||
@@ -6,7 +6,7 @@ This package is not in any way affiliated with LinkedIn. In fact, your account m
|
||||
|
||||
You can use your LinkedIn credentials in code, making this super simple to use!
|
||||
|
||||
*This project was HEAVILY inspired by Tomquirk's LinkedIn-API PyPy package, which you can find at https://github.com/tomquirk/linkedin-api*
|
||||
*This project was HEAVILY inspired by Tomquirk's LinkedIn-API PyPi package, which you can find at https://github.com/tomquirk/linkedin-api*
|
||||
|
||||
## Installation
|
||||
`npm i linkedin-api-js`
|
||||
|
||||
@@ -226,6 +226,53 @@ export default class linkedInAPIClass {
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param {number[]} conDeg
|
||||
* @param {number} [limit=1000]
|
||||
*/
|
||||
async getConnections(entityNameJoined, entityUrn, conDeg, limit = 1000, start = 0) {
|
||||
const empAll = [];
|
||||
|
||||
if (this.logAll) console.log(`scanning for ${limit} connections for user "${entityNameJoined}"`);
|
||||
|
||||
const lb = (this.logAll) ? new LoadingBar(Math.round(limit / 50)) : null;
|
||||
|
||||
for (let i = start; empAll.length < limit; i += 50) {
|
||||
let urlExt = `variables=(start:${i},origin:MEMBER_PROFILE_CANNED_SEARCH,memberIdentity:${entityNameJoined},query:(flagshipSearchIntent:SEARCH_SRP,queryParameters:List((key:connectionOf,value:List(${entityUrn})),(key:network,value:List(${numToConDegs(conDeg)})),(key:resultType,value:List(PEOPLE))),includeFiltersInResponse:false))`;
|
||||
const r = await this._makeReq(urlExt);
|
||||
|
||||
if (!r?.included && r?.data?.errors) {
|
||||
console.error(JSON.stringify(r.data.errors))
|
||||
throw "ERROR!";
|
||||
}
|
||||
else if (!r?.data.included) break;
|
||||
|
||||
empAll.push(r);
|
||||
|
||||
if (this.logAll) lb.increment(Math.ceil(r.included.length / 50));
|
||||
await this.evade();
|
||||
}
|
||||
|
||||
return empAll.flat();
|
||||
}
|
||||
|
||||
|
||||
async sendConnectionRequest(memberURN, customMessage = undefined) {
|
||||
await this.evade();
|
||||
|
||||
const rPath = 'https://www.linkedin.com/voyager/api/voyagerRelationshipsDashMemberRelationships?action=verifyQuotaAndCreateV2&decorationId=com.linkedin.voyager.dash.deco.relationships.InvitationCreationResultWithInvitee-2';
|
||||
const body = {
|
||||
"invitee":
|
||||
{ "inviteeUnion": { "memberProfile": `urn:li:fsd_profile:${memberURN}` } },
|
||||
customMessage
|
||||
}
|
||||
const headers = this.headers;
|
||||
headers['x-li-pem-metadata'] = 'Voyager - Invitations - Actions=invite-send';
|
||||
|
||||
const r = await axios.post(rPath, body, { headers }); // await axios.get(rPath, body, { headers }).catch(_ => null).then(_ => null).finally(() => axios.post(rPath, body, { headers }));
|
||||
return r.data;
|
||||
}
|
||||
|
||||
/**
|
||||
* @returns {Promise<LinkedInProfile[]>}
|
||||
* @param {String} keyword the user to search for
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import linkedInAPIClass from "../index.js";
|
||||
import { numToConDegs } from "./API.js";
|
||||
|
||||
export class LinkedInProfile {
|
||||
/** @type {linkedInAPIClass} */
|
||||
@@ -29,12 +30,28 @@ export class LinkedInProfile {
|
||||
return '';
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {number[]} conDeg
|
||||
* @param {number} [limit=1000]
|
||||
*/
|
||||
async getConnections (conDeg, limit = 1000) {
|
||||
if (!this.isConnected) throw `USER ${this.name} IS OUT OF NETWORK!`;
|
||||
return await this.#APIRef.getConnections(this.entityNameJoined, this.entityUrn, conDeg, limit);
|
||||
}
|
||||
|
||||
/**
|
||||
* will send a friend request to this person
|
||||
* @param {string} message
|
||||
*/
|
||||
makeConnection = (message) => this.#APIRef.sendConnectionRequest(this.entityUrn, message);
|
||||
|
||||
constructor(jsonData, apiRef) {
|
||||
this.#APIRef = apiRef;
|
||||
this.name = jsonData.title ? jsonData.title.text : '';
|
||||
this.entityNameJoined = jsonData.navigationUrl?.split("/in/")[1]?.split("?")[0];
|
||||
this.profileUrl = jsonData.navigationUrl || '';
|
||||
this.trackingUrn = jsonData.trackingUrn || '';
|
||||
this.isConnected = (jsonData.entityCustomTrackingInfo?.memberDistance !== 'OUT_OF_NETWORK');
|
||||
|
||||
const match = jsonData.entityUrn?.match(/urn:li:fsd_profile:(.*?),/);
|
||||
this.entityUrn = match ? match[1] : '';
|
||||
|
||||
+1
-1
@@ -8,7 +8,7 @@
|
||||
},
|
||||
"type": "module",
|
||||
"name": "linkedin-api-js",
|
||||
"version": "1.0.0-21",
|
||||
"version": "1.0.0-22",
|
||||
"main": "index.js",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
|
||||
Reference in New Issue
Block a user