问题描述
我可以使用GMB
api进行localPost。
错误如下。
{
"error": {
"code": 400,"message": "Request contains an invalid argument.","errors": [
{
"message": "Request contains an invalid argument.","domain": "global","reason": "badRequest"
}
],"status": "INVALID_ARGUMENT"
}
}
我的源代码如下。 另外,我从github安装了google / apiclient,并从here
安装了GMB库。$mediaItem = new \Google_Service_MyBusiness_MediaItem();
$mediaItem->setSourceUrl("https://example.com/test");
$mediaItem->setMediaFormat('PHOTO');
$media[] = $mediaItem;
$post = new \Google_Service_MyBusiness_LocalPost();
$post->setSummary($summary);
$post->setCallToAction($callToAction);
$post->setMedia($media);
$obj = new \Google_Service_MyBusiness($client);
$obj->accounts_locations_localPosts->create($accountLocation,$post);
如果我注释掉
"$post->setMedia($media);",I can make localPost.
您对此有何建议?
最诚挚的问候,
解决方法
我解决了自己。
Before:
$mediaItem->setSourceUrl("https://example.com/test");
After:
$mediaItem->setSourceUrl("https://example.com/test.jpg");
之所以不能进行localPost,是因为图像扩展名应该是图像扩展名。 Google API不允许我们发布没有扩展名的图像。
干杯。