如何使用PHP MyBusiness API在Google上创建本地帖子? [英] How to create local post on google using PHP MyBusiness API?

查看:68
本文介绍了如何使用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);

这篇关于如何使用PHP MyBusiness API在Google上创建本地帖子?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆