Php Google MyBusiness REST API更新发布补丁方法请求错误
我想更新一篇关于google my business的特定帖子。我已经得到了Php Google MyBusiness REST API更新发布补丁方法请求错误,php,laravel,google-api,httprequest,google-api-php-client,Php,Laravel,Google Api,Httprequest,Google Api Php Client,我想更新一篇关于google my business的特定帖子。我已经得到了账户id,位置id,以及发布id。我正在使用urlhttps://mybusiness.googleapis.com/v4/{name=accounts/*/locations/*/localPosts/*}并在我的后端中执行PATCH方法。但当我更新时,它会给我一个 "code": 2, "field": "update_mask", "mes
账户id
,位置id
,以及发布id
。我正在使用urlhttps://mybusiness.googleapis.com/v4/{name=accounts/*/locations/*/localPosts/*}
并在我的后端中执行PATCH
方法。但当我更新时,它会给我一个
"code": 2,
"field": "update_mask",
"message": "update_mask is required"
我无法理解google中的更新页面这件事。有人能告诉我该怎么办吗?我正在使用laravel btw和curl库进行http请求。这是我的密码
public function updatePost(Request $request ){
$url = 'https://mybusiness.googleapis.com/v4/accounts/'.$request->account_id.'/locations/'.$request->location_id.'/localPosts/'.$request->post_id;
$body['languageCode'] = "en-US";
$body['summary'] = $request->summary;
$body['callToAction'] = ['actionType'=> 'Call'];
$body['media'][] = ['mediaFormat'=> 'PHOTO', "sourceUrl" => $request->imageURL];
//Static Token only since for testing
$headers = array(
'Content-Type: application/json',
'Accept: application/json',
'Authorization: Bearer '.'ya29.a0AfH6SMB_1iUG11qj72p-pn_gCkOjUEf-ctvTGnJZ6FNTUy0Q3dYP54TMvI0cr8o0ditLp7CaWOUX5CTWn4v2kyQ-hZKSyuEJu_rBYX7uxvX373I9iVRxoypIZ6xhWDYTr-A_DHcaxGPVs1yz5u-fkYvU-xDppkASNbg'
);
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl, CURLOPT_CUSTOMREQUEST, 'PATCH');
curl_setopt($curl, CURLOPT_POSTFIELDS, json_encode($body));
curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
$response = curl_exec($curl);
dd($response);
}
完整信息
{
"error": {
"code": 400,
"message": "Request contains an invalid argument.",
"status": "INVALID_ARGUMENT",
"details": [
{
"@type": "type.googleapis.com/google.mybusiness.v4.ValidationError",
"errorDetails": [
{
"code": 2,
"field": "update_mask",
"message": "update_mask is required"
}
]
}
]
}
}
补丁方法的文档
您需要为upateMask设置查询参数,如下所示
https://mybusiness.googleapis.com/v4/accounts/2323232334343/locations/232323232/localPosts/23232323232?updateMask=summary
但是,我无法编辑其他字段,例如标题
您找到编辑其他页面的方法了吗?您需要为upateMask设置查询参数,如下所示
https://mybusiness.googleapis.com/v4/accounts/2323232334343/locations/232323232/localPosts/23232323232?updateMask=summary
但是,我无法编辑其他字段,例如标题
您找到编辑其他字段的方法了吗?很明显,您需要将查询参数“updatemask”设置为要更新的字段。查看详细信息。它的明确状态是,您需要将查询参数“updatemask”设置为要更新的字段。查看详细信息