首页 文章

如何使用PHP MyBusiness API在谷歌上创建本地帖子?

提问于
浏览
0

我想使用谷歌的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的字符串 .

上面的代码抛出异常'请求包含无效的参数 . '

我想知道如何使用PHP api创建帖子或帖子数据 .

任何帮助,将不胜感激 .

1 回答

  • 0

    对于拥有十多个地点的品牌,不允许通过API在GMB上发布 . 拉位置并检查此标志 $location->getLocationState()->getIsLocalPostApiDisabled().

    在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);
    

相关问题