I am trying to make Google My Business localPost for topicType offer in PHP.
I installed google/apiclient 2.7. Also, I have client library from GMB site as following. https://developers.google.com/my-business/samples/google-api-services-mybusiness-v4p7-php-rev-20200824-1.zip
I made following source code.
$offer = new \Google_Service_MyBusiness_LocalPostOffer();
$offer->setCouponCode($couponCode);
$offer->setTermsConditions($termsCondition);
$offer->setRedeemOnlineUrl($redeemOnlineUrl);
$schedule = new \Google_Service_MyBusiness_TimeInterval();
$date = new \Google_Service_MyBusiness_Date();
$date->setDay(6);
$date->setMonth(10);
$date->setYear(2020);
$time = new \Google_Service_MyBusiness_TimeOfDay();
$time->setHours(10);
$time->setMinutes(0);
$time->setMinutes(0);
$time->setSeconds(0);
$time->setNanos(0);
$schedule->setStartDate($date);
$schedule->setStartTime($time);
$date->setDay(6);
$date->setMonth(10);
$date->setYear(2020);
$time->setHours(19);
$time->setMinutes(0);
$time->setSeconds(0);
$time->setNanos(0);
$schedule->setEndDate($date);
$schedule->setEndTime($time);
$event = new \Google_Service_MyBusiness_LocalPostEvent();
$event->setTitle($title);
$event->setSchedule($schedule);
$post = new \Google_Service_MyBusiness_LocalPost();
$post->setSummary($summary);
$post->setOffer($offer);
$post->setEvent($event);
$post->setTopicType("OFFER");
$obj = new \Google_Service_MyBusiness($this->getClient('mybusiness'));
$obj->accounts_locations_localPosts->create($accountLocation,$post)
However, it give me following 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"
}
}
Do you have any suggetion for this?
Best regards,
The reason why I could not post offer is I did not reinitialise the followings when I set endDate and endTime.
So, I might reinitialize as followings.