# Direct WeChat MP API Diagnostic

When we-mp-rss shows 0 articles and journal logs are unreachable (process output → socket, not file),
call the WeChat MP API directly with the stored token/cookie. This bypasses:
- The async thread in `update_mps()` (always returns `[]`)
- The internal rate limiter (40402)
- Opaque background thread errors

## Prerequisites

The token and cookie must exist in Redis (login succeeded). Verify first:
```bash
redis-cli GET werss:login:status  # must return "1"
```

## Diagnostic Script

Copy-paste this, replacing only the faker_id if checking a different feed:

```python
import json, requests, urllib3
urllib3.disable_warnings()

import sys
sys.path.insert(0, '/home/ubuntu/project/we-mp-rss-main')
from driver.token import get as get_token_val

cookie = get_token_val('cookie', '')
token = get_token_val('token', '')

print(f"Token: {token[:30] if token else 'EMPTY'}...")
print(f"Cookie length: {len(cookie)}")

if not token:
    print("NO TOKEN — cannot fetch")
    exit()

# WeChat MP article list API
url = "https://mp.weixin.qq.com/cgi-bin/appmsgpublish"
params = {
    "sub": "list",
    "sub_action": "list_ex",
    "begin": 0,
    "count": 5,
    "fakeid": "MzU5NjI5NTkxMQ==",  # 中职生 — change for other feeds
    "token": token,
    "lang": "zh_CN",
    "f": "json",
    "ajax": 1
}
headers = {
    "Cookie": cookie,
    "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36",
    "Referer": "https://mp.weixin.qq.com/"
}

resp = requests.get(url, params=params, headers=headers, timeout=30, verify=False)
data = resp.json()

ret = data.get('base_resp', {}).get('ret', '?')
err_msg = data.get('base_resp', {}).get('err_msg', '?')

print(f"\nHTTP: {resp.status_code}")
print(f"base_resp.ret: {ret}")
print(f"base_resp.err_msg: {err_msg}")

# Interpret results
if ret == 200013:
    print("\n→ DIAGNOSIS: freq control — IP permanently blocked. Need proxy.")
elif ret == 200003:
    print("\n→ DIAGNOSIS: Invalid Session — login expired. Need QR re-scan.")
elif ret == 0:
    if 'publish_page' in data:
        pp = json.loads(data['publish_page'])
        count = len(pp.get('publish_list', []))
        print(f"\n→ DIAGNOSIS: Success! {count} articles available.")
        for item in pp.get('publish_list', [])[:2]:
            pi = json.loads(item.get('publish_info', '{}'))
            for art in pi.get('appmsgex', [])[:2]:
                print(f"  - {art.get('title', '?')[:60]}")
    else:
        print("\n→ DIAGNOSIS: ret=0 but no publish_page — possible genuine empty")
else:
    print(f"\n→ DIAGNOSIS: Unknown error code {ret}: {err_msg}")
```

## Feed Faker IDs

| Feed | faker_id |
|------|----------|
| 中职生 | `MzU5NjI5NTkxMQ==` |
| 广东中职菌 | `Mzg4Njg2NDQ3MA==` |

Find from DB: `SELECT faker_id, mp_name FROM feeds`
