我想向用户的Google +帐户发帖。我有一个使用带有schema.org标记的google页面的示例。这是请求中发送的帖子正文:
{
"type": "http://schema.org/AddAction",
"object": {
"url": "https://developers.google.com/+/web/snippet/examples/thing"
}
}
此网址的架构标记如下所示:
<!DOCTYPE html>
<html>
<head>
<title>The Google+ Platform</title>
<link rel="shortcut icon" href="thing.ico" />
</head>
<body itemscope itemtype="http://schema.org/Thing">
<section>Name: <div itemprop="name">The Google+ Platform</div></section>
<section>Description: <div itemprop="description">Google+ is more than just
plus.google.com. It's about adding people to all Google products. The
Google+ platform extends this idea, allowing you to add people to your
products too.</div></section>
<section>
Thumbnail: <img itemprop="image" src="thing.png"/>
</section>
</body>
</html>
当我使用此示例发出请求时,它可以正常工作。但是当我在自己网站的页面上使用相同的标记时,我得到了这个错误响应:
{
"error": {
"errors": [
{
"domain": "global",
"reason": "badRequest",
"message": "Unable to fetch metadata."
}
],
"code": 400,
"message": "Unable to fetch metadata."
}
}
它必须与url有关,而不是我的结构化标记。该网址看起来像https://mysite/path/view.html,当我使用google structured data testing tool时,会提取元数据。我试图省略对象网址,而是在帖子正文中指定元数据,如
'"object": {
"kind": "plus#itemScope",
"id": "id",
"description": "description",
...
但这不起作用。我正在使用PHP和cURL发送请求。我知道google api的php客户端库会更好,但我在这种情况下使用cURL。