【问题标题】:post on Google plus stream with custom Content使用自定义内容在 Google plus 流上发帖
【发布时间】:2014-04-09 12:11:21
【问题描述】:

我想知道,有没有办法将我们的格式化(粗体和斜体或\n)文本发布为用户流上的发布内容(使用谷歌加 Api)。

我尝试过 google 提供的 Intractive Posts 和 share dialog,但它们不支持格式化内容。

【问题讨论】:

  • 请提供更多详细信息。您如何尝试格式化内容。这种格式会发生什么,等等。
  • 我尝试过
    &nbsp 和其他 HTML 标签,但谷歌将所有标签显示为对话框中的内容。你可以看到#class演示链接。
  • Google+ 不支持帖子中的 HTML 格式。您是否尝试过使用 G+ 支持的格式? _italic_ *bold* -striketrhough-
  • 不工作。你可以查看这个演示 [wheresgus.com/ipostdemo/]

标签: google-plus


【解决方案1】:

据我所知,您无法控制 Google 根据您的网页内容计算出的内容是否为粗体。但是,在帖子内容中,您可以 * BOLD * 和 _ ITALICIZE _ 使用类似于 markdown 的标签。因为您可以在交互式帖子中预先填写文本,所以您可以为您的用户预先填写一些粗体字词,建议他们强调您网站分享中的内容。

一些代码:

这在您的页面标题标签中

<script type="text/javascript">
  (function() {
   var po = document.createElement('script'); po.type = 'text/javascript'; po.async = true;
   po.src = 'https://apis.google.com/js/client:plusone.js';
   var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(po, s);
 })();
</script>

...这在体内

<!-- Place the tag where you want the button to render -->
<span
  class="g-interactivepost"
  data-contenturl="http://wheresgus.com/ipostdemo/gplusbw.png"
  data-contentdeeplinkid="/nothingtoseehere"
  data-clientid="268858962829.apps.googleusercontent.com"
  data-cookiepolicy="single_host_origin"
  data-prefilltext="Prefill *bold* and _italic_ content."
  data-calltoactionlabel="JOIN"
  data-calltoactionurl="https://plus.google.com/+GusClass"
  data-calltoactiondeeplinkid="/account/signup">
<img src="gplusbw.png" width=28 height=23>
</span>

Demo here.

【讨论】:

  • 你的例子有同样的问题。 Google plus API 无法识别 HTML 或任何标签,而是将它们视为内容。
  • 它确实将它们视为内容,但是当用户分享内容时,**内容**会显示为粗体。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2014-07-25
相关资源
最近更新 更多