feat: add WeChat Channels (视频号) platform
This commit is contained in:
parent
cf652b061d
commit
004fd713b8
@ -153,3 +153,21 @@ def publish_twitter(platform, content):
|
|||||||
return ('POST', 'https://api.twitter.com/2/tweets', headers, body, 'article')
|
return ('POST', 'https://api.twitter.com/2/tweets', headers, body, 'article')
|
||||||
|
|
||||||
register('twitter', 'Twitter/X', publish_twitter, ['article', 'image', 'video'])
|
register('twitter', 'Twitter/X', publish_twitter, ['article', 'image', 'video'])
|
||||||
|
|
||||||
|
# -- 微信视频号 --
|
||||||
|
def publish_channels(platform, content):
|
||||||
|
headers = _auth_headers(platform)
|
||||||
|
headers['Content-Type'] = 'application/json'
|
||||||
|
body = {
|
||||||
|
'title': content.get('title', '')[:50],
|
||||||
|
'description': content.get('body', '')[:500],
|
||||||
|
'cover_url': content.get('cover_url', ''),
|
||||||
|
}
|
||||||
|
if content['content_type'] == 'video' and content.get('media_urls'):
|
||||||
|
body['video_url'] = json.loads(content['media_urls'])[0]
|
||||||
|
elif content.get('media_urls'):
|
||||||
|
body['image_urls'] = json.loads(content['media_urls'])[:9]
|
||||||
|
return ('POST', platform.get('api_endpoint', 'https://channels.weixin.qq.com/api/post/create'),
|
||||||
|
headers, body, content['content_type'])
|
||||||
|
|
||||||
|
register('channels', '微信视频号', publish_channels, ['video', 'image'])
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user