如何使用PHP MyBusiness API在Google上创建本地帖子?
我想使用Google的PHP My Business API V4在Google上创建本地帖子.
I want to create local post on google using google's PHP My Business API V4.
示例代码如下
$mybusinessService = new \Google_Service_MyBusiness($client);
$local = new \Google_Service_MyBusiness_LocalPost();
$path = $locname.'/localPosts';
$response = $mybusinessService->accounts_locations_localPosts->create($path,$local);
其中$ locname是帐户/位置ID的字符串.
where $locname is string of accounts/locations id.
上面的代码引发异常请求包含无效的参数."
above code throws exception 'Request contains an invalid argument.'
我想知道如何使用PHP api创建发布或发布数据.
I want to know that how to create post or post data using PHP api.
任何帮助将不胜感激.
对于位置超过十个的品牌,不允许通过API在GMB上发布.拉出位置并检查此标志 $ location-> getLocationState()-> getIsLocalPostApiDisabled()
.
For brands that have more than ten locations are not allowed to post on GMB through the API. Pull the location and check this flag $location->getLocationState()->getIsLocalPostApiDisabled()
.
在GMB Ex上发布.
Posting on GMB Ex.
$posts = $mybusinessService->accounts_locations_localPosts;
$newPost = new Google_Service_MyBusiness_LocalPost();
$newPost->setSummary("Order your Thanksgiving turkeys now!!");
$newPost->setLanguageCode("en-US");
$calltoaction = new Google_Service_MyBusiness_CallToAction();
$calltoaction->setActionType("ORDER");
$calltoaction->setUrl("http://google.com/order_turkeys_here");
$newPost->setCallToAction($calltoaction);
$media = new Google_Service_MyBusiness_MediaItem();
$media->setMediaFormat("PHOTO");
$media->setSourceUrl("https://www.google.com/real-turkey-photo.jpg");
$newPost->setMedia($media);
$listPostsResponse = $posts->create($location_name, $newPost);