php-google-my-business icon indicating copy to clipboard operation
php-google-my-business copied to clipboard

How to edit and delete any post from Google My Business

Open dhirendralab opened this issue 5 years ago • 1 comments

Kindly provide examples of edit and delete the post from Google My Business

dhirendralab avatar Sep 16 '20 12:09 dhirendralab

what's wrong in below code

`$name_post = "accounts/xxxx/locations/xxxx/localPosts/xxxx"; $post_body = new \Google_Service_MyBusiness_LocalPost; $post_body->setLanguageCode('en'); $post_body->setSummary('test_new'); // post text $call = new \Google_Service_MyBusiness_CallToAction; $call->setActionType('LEARN_MORE'); $call->setUrl('https://www.xyz.net/'); // URL to link to $post_body->setCallToAction($call); $media = new \Google_Service_MyBusiness_MediaItem; $media->setMediaFormat('PHOTO'); $media->setSourceUrl('https://www.xyz.net/modules/images/home.jpg'); $post_body->setMedia($media); try {

$resp = $mybusinessService->accounts_locations_localPosts->patch($name_post, $post_body); 
var_dump($resp);
die;

} catch (\Google_Service_Exception $e) { print_r($e); }`

getting error message

"error": { "code": 400, "message": "Request contains an invalid argument.", "errors": [ { "message": "Request contains an invalid argument.", "domain": "global", "reason": "badRequest" } ], "status": "INVALID_ARGUMENT" }

dhirendralab avatar Sep 17 '20 07:09 dhirendralab