Skill 详情

linkedin

Useful company-page publishing integration, but requires organization-specific credentials.

匹配类型可能匹配已针对 linkedin 审核
来源teamday-ai/agents外部来源
报告安装量1仅表示受欢迎程度

使用前先检查

自动化审核只检查相关性,不代表安全审查或推荐。使用前请阅读来源中的说明。

已保存的来源预览

SKILL.md

这段内容是审核时保存的快照。外部来源才是完整且最新的版本。

---
name: linkedin
description: Post updates to a LinkedIn company page. Use for sharing blog posts, product updates, AI-generated content, and company announcements. Supports text posts, article shares with link previews, and image posts.
version: 1.0.0
allowed-tools: Bash, Read
env:
  - LINKEDIN_ACCESS_TOKEN
  - LINKEDIN_ORG_ID
metadata:
  requires: credential-activation
  credentials:
    - LINKEDIN_ACCESS_TOKEN
    - LINKEDIN_ORG_ID
---

# LinkedIn Skill

Post content to a LinkedIn organization page using the LinkedIn REST API.

## Prerequisites

Credentials must be configured as Space environment variables.

| Variable | Required | Description | Example |
|----------|----------|-------------|---------|
| `LINKEDIN_ACCESS_TOKEN` | Yes | OAuth 2.0 Bearer token (expires every 2 months) | `AQV...` |
| `LINKEDIN_ORG_ID` | Yes | LinkedIn organization numeric ID | `104061442` |

### Verify Setup

```bash
echo "LINKEDIN_ACCESS_TOKEN: ${LINKEDIN_ACCESS_TOKEN:+configured (${#LINKEDIN_ACCESS_TOKEN} chars)}"
echo "LINKEDIN_ORG_ID: ${LINKEDIN_ORG_ID:-not set}"
```

If not configured, use the `credential-activation` skill to guide the user through setup.

## API Basics

All requests use these common headers:

```bash
-H "Authorization: Bearer $LINKEDIN_ACCESS_TOKEN" \
-H "Linkedin-Version: 202601" \
-H "X-Restli-Protocol-Version: 2.0.0" \
-H "Content-Type: application/json"
```

The author field for organization posts is always: `urn:li:organization:$LINKEDIN_ORG_ID`

## Verify Credentials

Check that the token is valid before posting:

```bash
RESPONSE=$(curl -s -w "\n%{http_code}" \
  -H "Authorization: Bearer $LINKEDIN_ACCESS_TOKEN" \
  -H "Linkedin-Version: 202601" \
  -H "X-Restli-Protocol-Version: 2.0.0" \
  "https://api.linkedin.com/rest/organizationsLookup?ids=List($LINKEDIN_ORG_ID)&fields=localizedName")

HTTP_CODE=$(echo "$RESPONSE" | tail -n1)
BODY=$(echo "$RESPONSE" | sed '$d')

if [ "$HTTP_CODE" -eq 200 ]; then
  echo "Token valid. Organization: $(echo "$BODY" | grep -o '"localizedName":"[^"]*"' | head -1)"
else
  echo "Token invalid or expired (HTTP $HTTP_CODE). Re-run OAuth flow to get a new token."
  echo "Error: $BODY"
fi
```

## Text Post

Create a simple text-only post on the company page:

```bash
POST_TEXT="Your post content here. Supports multi-line text, emojis, and hashtags like #AI #YourBrand"

RESPONSE=$(curl -s -w "\n%{http_code}" -X POST \
  "https://api.linkedin.com/rest/posts" \
  -H "Authorization: Bearer $LINKEDIN_ACCESS_TOKEN" \
  -H "Linkedin-Version: 202601" \
  -H "X-Restli-Protocol-Version: 2.0.0" \
  -H "Content-Type: application/json" \
  -d "{
    \"author\": \"urn:li:organization:$LINKEDIN_ORG_ID\",
    \"commentary\": \"$POST_TEXT\",
    \"visibility\": \"PUBLIC\",
    \"distribution\": {
      \"feedDistribution\": \"MAIN_FEED\",
      \"targetEntities\": [],
      \"thirdPartyDistributionChannels\": []
    },
    \"lifecycleState\": \"PUBLISHED\",
    \"isReshareDisabledByAuthor\": false
  }")

HTTP_CODE=$(echo "$RESPONSE" | tail -n1)
BODY=$(echo "$RESPONSE" | sed '$d')

if [ "$HTTP_CODE" -eq 201 ]; then
  POST_ID=$(echo "$BODY" | grep -o '"id":"[^"]*"' | head -1 | cut -d'"' -f4)
  echo "Post published successfully. ID: $POST_ID"
else
  echo "Failed to create post (HTTP $HTTP_CODE): $BODY"
fi
```

## Article Share (URL with Link Preview)

Share a URL with commentary — LinkedIn auto-generates a link preview card:

```bash
ARTICLE_URL="https://your-domain.com/blog/your-article"
ARTICLE_TITLE="Your Article Title"
ARTICLE_DESCRIPTION="Brief description of the article"
COMMENTARY="Check out our latest blog post on AI agents for business automation. #AI #Productivity"

RESPONSE=$(curl -s -w "\n%{http_code}" -X POST \
  "https://api.linkedin.com/rest/posts" \
  -H "Authorization: Bearer $LINKEDIN_ACCESS_TOKEN" \
  -H "Linkedin-Version: 202601" \
  -H "X-Restli-Protocol-Version: 2.0.0" \
  -H "Content-Type: application/json" \
  -d "{
    \"author\": \"urn:li:organization:$LINKEDIN_ORG_ID\",
    \"co
在 GitHub 阅读完整来源 (打开外部页面)
相关上下文

相关工作