Tumblr API 确实令人印象深刻,因为它允许我直接发布到博客中。不过,我也想添加meta
Twitter 卡。有什么办法可以做到这一点?
client = pytumblr.TumblrRestClient(
app.config['CONSUMER_KEY'],
app.config['CONSUMER_SECRET'],
app.config['OAUTH_TOKEN'],
app.config['OAUTH_SECRET'],
)
if news.is_published:
body = ''
if news.image_url_list and len(news.image_url_list) > 0:
body = '<img src="{0}" /><br/>'.format(news.image_url_list[0])
slug = Slugify.slugify(news.head_line)
post = client.create_text("xxx.tumblr.com",
state="published",
tags=news.tag_list,
format='html',
slug=slug,
title=news.head_line,
body=body + news.summary.encode('utf-8'))
如何将这些元标记添加到博客文章中?
<meta name="twitter:card" content="summary" />
<meta name="twitter:site" content="@flickr" />
<meta name="twitter:title" content=? news.head_line ? />
<meta name="twitter:description" content=? news.description ? />
<meta name="twitter:image" content=? news.image_url_list[0] ? />