POST
/api/v4/posts创建公告帖子
创建 ANNOUNCEMENT 社交帖子,并将其发布到一个或多个地点的所选站点。
参数
请求体
| 名称 | 类型 | 必填 | 描述 |
|---|---|---|---|
| input | object | 必填 | Wrapper object. Every field below is a property of `input`, the entire body must be nested under it. |
| input.postName | string | 必填 | Internal name for the campaign (not shown to customers). |
| input.locationIds | array of strings | 必填 | Base64-encoded location IDs to publish to (e.g. `TG9jYXRpb246MTgwMDI4OQ==`). |
| input.postType | string | 必填 | Must be `ANNOUNCEMENT`. One of EVENT, OFFER, ANNOUNCEMENT, COVID19, PRODUCT. |
| input.postSites | array of strings | 必填 | Sites to publish to: `GOOGLE`, `FACEBOOK`. |
| input.postMessage | array of objects | 可选 | Per-site body text: `{ site, message }`. Provide one entry per site in `postSites`. |
| input.postCta | array of objects | 可选 | Optional call-to-action button per site: `{ site, type, url }`. `type` is one of BOOK, ORDER, SHOP, LEARN_MORE, SIGN_UP, GET_OFFER. |
| input.postMediaUrl | array of objects | 可选 | Optional media per site: `{ site, url, type }` where `type` is IMAGE or VIDEO. |
| input.clientMutationId | string | 可选 | Optional client token returned unchanged in the response for correlation. |
请求示例
可直接粘贴的请求体。请将占位 ID 和值替换为您自己的。
{ "input": { "postName": "Grand Opening Announcement", "locationIds": ["TG9jYXRpb246MTgwMDI4OQ=="], "postType": "ANNOUNCEMENT", "postSites": ["GOOGLE"], "postMessage": [ { "site": "GOOGLE", "message": "We are now open! Visit Jenny Home this week for our grand opening." } ], "postCta": [ { "site": "GOOGLE", "type": "LEARN_MORE", "url": "https://jennyhome.example/opening" } ], "postMediaUrl": [ { "site": "GOOGLE", "url": "https://cdn.example.com/opening.jpg", "type": "IMAGE" } ] }}响应
200Post accepted. Publishing runs asynchronously, the returned post starts as INPROGRESS.
{ "data": { "createSocialPost": { "clientMutationId": null, "success": true, "errors": [], "socialPost": { "id": "U29jaWFsUG9zdDo0NDEyMg==", "name": "Grand Opening Announcement", "status": "INPROGRESS", "type": "ANNOUNCEMENT", "createdAt": "2026-06-28", "sites": ["GOOGLE"], "message": [ { "site": "GOOGLE", "message": "We are now open! Visit Jenny Home this week for our grand opening." } ], "cta": [ { "type": { "value": "LEARN_MORE", "label": "Learn more" }, "url": "https://jennyhome.example/opening", "site": "GOOGLE", "tinyUrl": null } ], "contextInfo": null, "mediaUrl": [ { "url": "https://cdn.example.com/opening.jpg", "site": "GOOGLE", "type": "IMAGE" } ], "publishDetails": [ { "site": "GOOGLE", "status": "PUBLISHING", "createdDate": "2026-06-28", "submissionError": null } ], "postLinks": [], "locationIds": [1800289] } } }}400Bad request, the body was not wrapped in `input` (error message: `Variable "$input" of required type "CreateSocialPostMutationInput!" was not provided`).
401Unauthenticated, missing or invalid API key.
创建公告:最简单的帖子类型。公告包含一条纯文本消息(以及可选的 CTA 和图片),不包含活动日期或优惠详情。传入 postType: "ANNOUNCEMENT",并在 postSites 中为每个站点提供一个 postMessage 条目。
使用场景:在您的各家门店发布“我们开业了”。 通过一次调用,为一组地点向 Google(和 Facebook)发布盛大开业或新营业时间的公告。提供一个链接到您网站的 LEARN_MORE CTA 和一张图片,让卡片内容更丰富。调用会立即返回 status: INPROGRESS;使用返回的 socialPost.id 轮询 GET /posts/{postId},直到状态为 SUCCESS;如果有站点发布失败,请读取 publishDetails[].submissionError。
注意事项。
- 请求体必须封装在
input对象中:每个字段(postName、locationIds、postType、postSites等)都是input的属性。未封装的扁平请求体会被拒绝,并返回 HTTP 400(Variable "$input" of required type "CreateSocialPostMutationInput!" was not provided)。 postSites和每个postMessage.site都使用站点枚举(GOOGLE、FACEBOOK);请为每个目标站点提供一个消息条目。- 要将同一公告发布到多个地点,您可以在此处的
locationIds中传入所有 ID,也可以使用POST /bulk-posts进行大规模多地点发布。 - 对于带日期的帖子,请使用 活动;对于优惠券或折扣,请使用 优惠。
写入操作:未在实际账户中执行。所示请求和响应根据 API schema 构建;实际运行时,会向真实的 Google/Facebook 商家资料发布帖子。
Request
curl -X POST 'https://listingsapi.com/api/v4/posts' \ -H "Authorization: API $LISTINGSAPI_KEY" \ -H 'Content-Type: application/json' \ -d '{ "input": { "postName": "Grand Opening Announcement", "locationIds": [ "TG9jYXRpb246MTgwMDI4OQ==" ], "postType": "ANNOUNCEMENT", "postSites": [ "GOOGLE" ], "postMessage": [ { "site": "GOOGLE", "message": "We are now open! Visit Jenny Home this week for our grand opening." } ], "postCta": [ { "site": "GOOGLE", "type": "LEARN_MORE", "url": "https://jennyhome.example/opening" } ], "postMediaUrl": [ { "site": "GOOGLE", "url": "https://cdn.example.com/opening.jpg", "type": "IMAGE" } ] } }'