我们有一个管理多个位置的“Google 我的商家”帐户。我想创建一个用于回答问题的界面。我的问题是我找不到如何检索当前位置的 Author 对象。
我尝试创建一个新的 Google_Service_MyBusiness_Author 对象并提交它,但它似乎不起作用。我正在使用 MyBusiness API 4.5
$author = new Google_Service_MyBusiness_Author();
$author->setDisplayName('location display name');
$author->setProfilePhotoUrl('someurl.jpg');
$author->setType('MERCHANT');
$answer = new Google_Service_MyBusiness_Answer();
$answer->setText($_POST['answerReplyText']);
$answer->setAuthor($author);
$postBody = new Google_Service_MyBusiness_UpsertAnswerRequest();
$postBody->setAnswer($answer);
try {
$mybusinessService->accounts_locations_questions_answers->upsert($_POST['question_name'],$postBody);
}
catch(Exception $e) {
var_dump($e);
}
我收到“请求包含无效参数”异常。我这样做是对的吗?我应该怎么做才能使我的答案有效?
最佳答案
请通过删除仅输出字段来尝试以下操作:
// $author = new Google_Service_MyBusiness_Author();
// $author->setDisplayName('location display name');
// $author->setProfilePhotoUrl('someurl.jpg');
// $author->setType('MERCHANT');
$answer = new Google_Service_MyBusiness_Answer();
$answer->setText($_POST['answerReplyText']);
// $answer->setAuthor($author);
$postBody = new Google_Service_MyBusiness_UpsertAnswerRequest();
$postBody->setAnswer($answer);
try {
$mybusinessService->accounts_locations_questions_answers->upsert($_POST['question_name'],$postBody);
}
catch(Exception $e) {
var_dump($e);
}
这对我来说效果很好。希望这对您也有帮助。
https://stackoverflow.com/questions/58080848/
相关文章:
microsoft-graph-api - 更新和删除日历事件而不向与会者发送通知
reactjs - 如何使用带有反应最终形式的自定义 radio 组件?
azure-sql-database - 目前无法检索该地区的定价配置数据。请重试
c# - 配置生成器 - 无法加载程序集 - .Net Framework
php - 未定义的方法 Laravel\Lumen\Application::booted()
visual-studio-code - 如何使用 Visual Studio Code + VSC