LinkedIn integration via Unipile's official Node.js SDK. Send messages, InMail, view profiles, manage connections, create posts, and interact with content. Use for LinkedIn automation, messaging, profile retrieval, connection requests, or post interactions. Trigger phrases: "linkedin api", "scrape linkedin", "linkedin profile", "linkedin posts", "send linkedin message".
通过官方Unipile Node.js SDK实现LinkedIn API,支持消息、个人资料、帖子和邀请功能。
推荐: 设置 UNIPILE_PERMISSIONS=read 以启用只读访问。
bash
您的访问令牌可以代表您执行操作。请使用 UNIPILE_PERMISSIONS 限制其作用范围。
bash
npm install unipile-node-sdk
| 变量 | 必需 | 描述 |
|---|---|---|
| UNIPILEDSN | ✅ 是 | API端点(例如 https://api34.unipile.com:16473) |
| UNIPILEACCESSTOKEN |
| 模式 | UNIPILE_PERMISSIONS | 允许的操作 | 使用场景 |
|---|---|---|---|
| 只读 ⭐ | read | 列出个人资料、帖子、聊天、消息、连接 | 数据抓取、仪表盘、分析 |
| 只写 |
默认值: read,write(完全访问)— 为安全起见,请更改为 read。
bash
javascript
import { UnipileClient } from unipile-node-sdk;
const client = new UnipileClient(
process.env.UNIPILE_DSN,
process.env.UNIPILEACCESSTOKEN
);
// 操作前检查权限
const canWrite = (process.env.UNIPILE_PERMISSIONS || read,write).includes(write);
const canRead = (process.env.UNIPILE_PERMISSIONS || read,write).includes(read);
推荐方法(按安全性排序):
避免: 将令牌以明文形式存储在文件中,尤其是在共享或版本控制的目录中。
通过Unipile连接我的LinkedIn账户
列出我已连接的LinkedIn账户
我的LinkedIn个人资料信息是什么?
模式: 首先获取账户ID,然后将其用于所有其他操作。
javascript
// 步骤1:获取您的LinkedIn账户ID
const accounts = await client.account.getAll();
const linkedin = accounts.items.find(a => a.type === LINKEDIN);
const accountId = linkedin.id; // 用于所有操作
// 步骤2:获取您自己的个人资料
const me = await client.users.getOwnProfile(accountId);
查看吴恩达的LinkedIn个人资料
获取萨提亚·纳德拉的LinkedIn工作经历部分
在LinkedIn上查找OpenAI的公司简介
javascript
// 通过公开标识符(URL slug)查询用户个人资料
const profile = await client.users.getProfile({
account_id: accountId,
identifier: andrewyng // 来自 linkedin.com/in/andrewyng
});
// 指定部分内容
const profile = await client.users.getProfile({
account_id: accountId,
identifier: satyanadella,
linkedin_sections: [experience, education, skills],
notify: true // 发送个人资料查看通知
});
// 公司简介
const company = await client.users.getCompanyProfile({
account_id: accountId,
identifier: openai // 公司URL slug
});
列出上周吴恩达在LinkedIn上的帖子
获取桑达尔·皮查伊最新的5条帖子
显示微软最近的LinkedIn帖子
吴恩达最近关于AI发了什么?
javascript
// 获取用户的帖子
const posts = await client.users.getAllPosts({
account_id: accountId,
identifier: andrewyng, // 或使用个人资料查询中的provider_id
limit: 10
});
// 按日期范围过滤(客户端)
const oneWeekAgo = new Date(Date.now() - 7 24 60 60 1000);
const recentPosts = posts.items.filter(p =>
new Date(p.parsed_datetime) >= oneWeekAgo
);
// 获取特定帖子的详细信息
const post = await client.users.getPost({
account_id: accountId,
post_id: posts.items[0].id
});
// 返回:点赞数、评论数、分享链接、文本等
// 在您自己的个人资料上创建帖子
await client.users.createPost({
account_id: accountId,
text: 很高兴分享我的最新项目!🚀
});
列出我的LinkedIn聊天
显示LinkedIn上未读的消息
给我上次的LinkedIn对话发送消息
javascript
// 列出所有聊天
const chats = await client.messaging.getAllChats({
account_type: LINKEDIN,
account_id: accountId,
limit: 20
});
// 过滤未读
const unreadChats = chats.items.filter(c => c.unread_count > 0);
// 获取聊天中的消息
const messages = await client.messaging.getAllMessagesFromChat({
chat_id: chats.items[0].id,
limit: 50
});
// 向现有聊天发送消息
await client.messaging.sendMessage({
chatid: chatid,
text: 感谢连接!
});
// 与某人开始新聊天
await client.messaging.startNewChat({
account_id: accountId,
attendeesids: [provideridfromprofile],
text: 你好,我想联系一下关于...
});
向网络外的人发送InMail
给未连接的LinkedIn用户发消息
javascript
await client.messaging.startNewChat({
account_id: accountId,
attendeesids: [targetprovider_id],
text: 你好,我看到了你的个人资料...,
options: {
linkedin: {
api: classic, // 或 recruiter, sales_navigator
inmail: true
}
}
});
注意:InMail需要LinkedIn Premium。
列出我的LinkedIn联系人
显示我待处理的连接请求
向[个人资料]发送连接请求
取消我向[姓名]发送的待处理邀请
javascript
// 列出您的联系人
const connections = await client.users.getAllRelations({
account_id: accountId,
limit: 100
});
// 发送连接请求
await client.users.sendInvitation({
account_id: accountId,
provider_id: ACoAAA..., // 来自个人资料查询
message: 你好,我很喜欢你最近关于AI的帖子!
});
// 列出您已发送的待处理邀请
const invitations = await client.users.getAllInvitationsSent({
account_id: accountId
});
// 取消邀请
await client.users.cancelInvitationSent({
account_id: accountId,
invitation_id: invitations.items[0].id
});
点赞吴恩达的最新帖子
在[帖子]上添加评论
在[帖子]上使用庆祝表情
javascript
//
该技能支持在以下平台通过对话安装:
帮我安装 SkillHub 和 unipile-linkedin-sdk-1776112102 技能
设置 SkillHub 为我的优先技能安装源,然后帮我安装 unipile-linkedin-sdk-1776112102 技能
skillhub install unipile-linkedin-sdk-1776112102
文件大小: 13.07 KB | 发布时间: 2026-4-14 13:43