我正在尝试使用GMB API将媒体上传到我的GMB帐户。
我已经安装了以下Goolge提供的库。
https://github.com/googleapis/google-api-php-client https://developers.google.com/my-business/samples/google-api-services-mybusiness-v4p6-php-rev-20200422-1.zip
谷歌支持的人说我们应该使用accounts.locations.media/create来上传媒体。
所以,我写了下面的源代码。
$obj = new \Google_Service_MyBusiness($this->getClient())
$obj->accounts_locations_media->create("accounts/000000/locations/00000",$mediaItem); 第一个参数没问题。但是,第二个参数$mediaItem应该是Google_Service_MyBusiness_MediaItem。
所以,我寻找Google_Service_MyBusiness_MediaItem,它看起来我们不能使用这个接口发布媒体。
如何使用API将媒体上传到GMB?
我对此有点困惑。
诚挚的问候,
发布于 2020-08-21 17:50:31
我找到了答案。我们必须上传一个我们可以访问的媒体。我们不能直接将媒体上传到GMB API。
$obj = new \Google_Service_MyBusiness($this->getClient('mybusiness'));
$media = new Google_Service_MyBusiness_MediaItem();
$media->setName('test');
$media->setSourceUrl('https://webdesign-trends.net/wp/wp-content/uploads/2019/01/the-best-free-stock-photo-sites-945x567.png');
$locationAssocition = new Google_Service_MyBusiness_LocationAssociation();
$locationAssocition->setCategory('CATEGORY_UNSPECIFIED');
$media->setLocationAssociation($locationAssocition);
$media->setMediaFormat("PHOTO");
$obj->accounts_locations_media->create($accountLocation,$media);https://stackoverflow.com/questions/63519111
复制相似问题