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 結構描述建構的;執行時,此操作會發布至真實的 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" } ] } }'