Skip to content

Add user and posts commands behind --cookie flag - #2

Merged
tamnd merged 4 commits into
mainfrom
cookie-user-posts
Jun 15, 2026
Merged

Add user and posts commands behind --cookie flag#2
tamnd merged 4 commits into
mainfrom
cookie-user-posts

Conversation

@tamnd

@tamnd tamnd commented Jun 15, 2026

Copy link
Copy Markdown
Owner

Summary

  • Two new commands: weibo user <uid> and weibo posts <uid> that read from
    Weibo's gated mobile API (m.weibo.cn/api/container/getIndex)
  • Pass session cookie with --cookie "SUB=xxx; SUBP=yyy" (global flag) or
    WEIBO_COOKIE env var; without it both commands exit 4 with a clear message
  • Added ExtendStatus API method to fetch the full text of long posts (isLongText: true)
  • Added parseUID to accept a numeric uid or any of the common profile URL forms
    (weibo.com/u/ID, m.weibo.cn/u/ID, m.weibo.cn/profile/ID)
  • New types: User and Post with kit table/url/body annotations
  • 12 new tests covering cookie threading, card-type filtering, limit, ParseUID,
    ExtendStatus, and the ok:-100 walled path

Why cookie, not visitor token

The passport.weibo.com/visitor/genvisitor2 endpoint returns a sub/subp
pair but they require a JS-driven crossdomain activation step
(document.cookie = 'SUB=' + sub running on sub.weibo.com) before the
values become valid session cookies. There is no way to replicate this in pure
HTTP without a browser runtime. The --cookie flag is the only reliable
approach without running a browser.

Test plan

  • go test ./... passes
  • go vet ./... and staticcheck ./... clean
  • weibo user <uid> without --cookie exits 4 with walled message
  • weibo user <uid> --cookie "SUB=xxx" with a real cookie returns profile
  • weibo posts <uid> --cookie "SUB=xxx" returns timeline posts

tamnd added 4 commits June 15, 2026 13:40
Two new ops (user, posts) read from Weibo's gated mobile API. They need a
SUB session cookie from a logged-in browser — pass it with --cookie or
WEIBO_COOKIE env.

Also adds ExtendStatus to fetch full long-post text, and parseUID to accept
a numeric uid or a profile URL (weibo.com/u/ID, m.weibo.cn/u/ID, /profile/ID).

Without --cookie the commands exit 4 (walled) with a clear message.
Tests cover cookie threading, card-type filtering, limit, ParseUID, and the
ok:-100 walled path.
Every scaffold page is replaced with real content:

- README: badges, commands table, usage examples with --cookie and
  WEIBO_COOKIE, global flags, exit codes, how it works, not-affiliated
  disclaimer
- _index.md: real command examples in the hero code block
- introduction.md: two-host architecture, access matrix table, what weibo
  cleans up (HTML, timestamps, IDs)
- quick-start.md: worked examples for all 6 commands, cookie setup walkthrough
- cli.md: full command table split by open/gated, all flags with defaults,
  exit code table
- configuration.md: WEIBO_COOKIE env var, cookie sourcing instructions, all
  global flags, rate/retry explanation
- troubleshooting.md: exit-4 cookie section, fix bogus -v flag reference,
  fix --rate guidance, add PATH section
- release-notes/_index.md: link list to v0.1.0 and v0.1.1
- release-notes/v0-1-0.md: first release notes (hot command)
- release-notes/v0-1-1.md: kit rebuild (status, comments, suggest)
- README/cli.md/configuration.md: add missing kit global flags
  (-v/--verbose, --dry-run, --no-cache, --data-dir, --db, --profile)
- README/cli.md/configuration.md: add list and markdown to output format lists
- output.md: add list and markdown formats with examples; replace generic
  <command> placeholders with real weibo commands
- README: go version 1.23+ -> 1.26+
- release-notes/_index.md: add FreeBSD, armv7, 386 to platform list
  (matches actual goreleaser targets)
- guides/_index.md: remove scaffold "add as you build" text
- .goreleaser.yaml: update nfpms/homebrew/scoop/docker descriptions from
  "Browse Weibo hot search topics" to "A command line for Weibo (微博)"
- weibo/domain.go: update Long help text to mention user/posts+cookie
  and the full output format list
@tamnd
tamnd merged commit dcb0690 into main Jun 15, 2026
@tamnd
tamnd deleted the cookie-user-posts branch June 15, 2026 11:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant