投稿

client.postsを通じて、お知らせ、イベント、特典をGoogleとFacebookに公開します。

投稿用のすべてのメソッドは client.posts にあります。location_id を受け取るメソッドは、数値または base64 エンコードされた ID を受け付けます。拠点 ID を参照してください。

投稿は GOOGLE と FACEBOOK の 2 つのサイトに公開されます。投稿タイプは ANNOUNCEMENT、EVENT、OFFER、COVID19、PRODUCT です。CTA のタイプは BOOK、ORDER、SHOP、LEARN_MORE、SIGN_UP、GET_OFFER です。cta_type と cta_url は必ず一緒に指定する必要があります。

非同期の公開処理

公開処理は非同期です。作成メソッドの呼び出しは status: INPROGRESS を返します。ステータスが SUCCESS になるまで posts.retrieve()(一括キャンペーンの場合は posts.bulk_retrieve())をポーリングし、publishDetails[].submissionError でサイトごとの失敗を確認してください。

サイトごとのメッセージ

すべての作成メソッドは、message として、すべてのサイトに同じテキストを公開する通常の文字列、またはサイトとテキストを対応付ける dict を受け付けます。

Python
message = {  "GOOGLE": "Book your summer checkup today!",  "FACEBOOK": "Summer checkups are here. Tag a friend who needs one!",}

message が dict の場合、sites 内のすべてのサイトに対応するエントリを含める必要があります。1 つでも欠けていると、SDK はネットワーク呼び出しを行う前に ValidationError を送出します。


posts.bulk_publish

1 回の呼び出しで、Google と Facebook の複数の拠点に同じ投稿を公開します。投稿にはこの方法を推奨します。sites はデフォルトで両方のサイトを対象とし、単一のメッセージ(またはサイトごとの dict)はサイトごとに 1 つのエントリに展開され、拠点 ID は自動的にエンコードされ、ペイロードはネットワーク呼び出しの前にクライアント側で検証されます。

Python
client.posts.bulk_publish(    *,    name: str,    location_ids: list[str | int],    message: str | dict[str, str],    sites: list[str] | None = None,    post_type: str = "ANNOUNCEMENT",    cta_type: str | None = None,    cta_url: str | None = None,    media_url: str | None = None,    scheduled_dates: dict | None = None,    context_info: dict | None = None,    additional_fields: dict | None = None,) -> APIObject
引数型説明
namestr内部用のキャンペーン名です(顧客には表示されません)。必須です。
location_idslist[str | int]公開先となるすべての拠点です(数値または base64 エンコードされた ID)。必須です。
messagestr | dictすべてのサイトに共通の投稿本文、またはサイトごとの dict です。必須です。
siteslist[str]対象サイトです。デフォルトは ["GOOGLE", "FACEBOOK"] です。
post_typestrANNOUNCEMENT(デフォルト)、EVENT、OFFER、COVID19、PRODUCT のいずれかです。
cta_typestr任意の CTA ボタンです。指定する場合は cta_url が必要です。
cta_urlstrCTA ボタンのリンク先です。
media_urlstr各サイトの投稿に添付する、公開アクセス可能な画像の URL です(任意)。
scheduled_datesdict任意の {"startDatetime", "endDatetime"} 期間です。
context_infodictpost_type で必要になる場合に指定する、イベントまたは特典の詳細です。
additional_fieldsdictそのままマージされる、フラットな構造の追加の camelCase フィールドです。
Python
result = client.posts.bulk_publish(  name="Holiday hours",  location_ids=[16808, 16809, 16810],  message="Open until 10pm through the holidays!",  media_url="https://cdn.example.com/holiday.jpg",  cta_type="LEARN_MORE",  cta_url="https://example.com/holiday-hours",)print(result.socialPost.id, result.socialPost.status)  # INPROGRESS, publishes async

posts.create_announcement

ANNOUNCEMENT 投稿を作成します。通常のメッセージに、任意で CTA とメディアを追加できます。sites のデフォルトは ["GOOGLE"] です。

Python
client.posts.create_announcement(    *,    name: str,    location_ids: list[str | int],    message: str | dict[str, str],    sites: list[str] | None = None,    cta_type: str | None = None,    cta_url: str | None = None,    media_url: str | None = None,    scheduled_dates: dict | None = None,    additional_fields: dict | None = None,) -> APIObject
Python
result = client.posts.create_announcement(  name="Grand Opening",  location_ids=[16808],  message="Acme Dental is now open!",  sites=["GOOGLE"],  cta_type="LEARN_MORE",  cta_url="https://acmedental.example.com/opening",)print(result.socialPost.id)

posts.create_event

タイトルと開始・終了期間を指定して EVENT 投稿を作成します。Google ではイベントのタイトルが必須であり、指定されていない場合、SDK は ValidationError を送出します。start_day と end_day は日付(YYYY-MM-DD)で、start_time と end_time は "10:00am" のような表示用の文字列です。

Python
client.posts.create_event(    *,    name: str,    location_ids: list[str | int],    message: str | dict[str, str],    title: str,    start_day: str,    end_day: str,    start_time: str | None = None,    end_time: str | None = None,    sites: list[str] | None = None,    cta_type: str | None = None,    cta_url: str | None = None,    media_url: str | None = None,    scheduled_dates: dict | None = None,    additional_fields: dict | None = None,) -> APIObject
Python
result = client.posts.create_event(  name="Free checkup day",  location_ids=[16808],  message="Join us for free dental checkups!",  title="Free Checkup Day",  start_day="2026-08-01",  end_day="2026-08-01",  start_time="10:00am",  end_time="4:00pm",  cta_type="BOOK",  cta_url="https://acmedental.example.com/book",)print(result.socialPost.id)

posts.create_offer

クーポン、割引、利用条件を指定して OFFER 投稿を作成します。title は特典の名前を指定する必須項目で、start_day と end_day(YYYY-MM-DD)はその有効期間の開始と終了を指定します。

Python
client.posts.create_offer(    *,    name: str,    location_ids: list[str | int],    message: str | dict[str, str],    title: str,    coupon_code: str | None = None,    discount: str | None = None,    redeem_url: str | None = None,    terms_conditions: str | None = None,    start_day: str | None = None,    end_day: str | None = None,    sites: list[str] | None = None,    cta_type: str | None = None,    cta_url: str | None = None,    media_url: str | None = None,    scheduled_dates: dict | None = None,    additional_fields: dict | None = None,) -> APIObject
Python
result = client.posts.create_offer(  name="Summer whitening sale",  location_ids=[16808],  message="20% off teeth whitening all week!",  title="Summer Whitening Sale",  coupon_code="SUMMER20",  discount="20%",  redeem_url="https://acmedental.example.com/sale",  terms_conditions="One per patient. Not valid with other offers.",  start_day="2026-08-01",  end_day="2026-08-07",)print(result.socialPost.id)

posts.create

リクエストボディを表す生の dict から投稿を作成します。camelCase にフィールドをフラットな構造で渡すと、ヘルパーは送信前にそれらを API が要求する input オブジェクトで囲むため、実際に送信されるリクエストボディは {"input": {...}} となり、フラットな構造にはなりません。locationIds は事前に base64 エンコードされている必要があります。キーワード引数、ID の自動エンコード、クライアント側の検証を利用するには、上記の型付き作成メソッドを優先して使用してください。

Python
client.posts.create(body: dict) -> APIObject

必須項目は postName、locationIds(base64)、postType、postSites です。

Python
result = client.posts.create({  "postName": "Grand Opening",  "locationIds": ["TG9jYXRpb246MTY4MDg="],  "postType": "ANNOUNCEMENT",  "postSites": ["GOOGLE"],  "postMessage": [{"site": "GOOGLE", "message": "We are now open!"}],})print(result.socialPost.id)

posts.retrieve

投稿を、その内容、サイトごとの公開ステータス、分析データとともに取得します。作成後、status が SUCCESS になるまでこのメソッドをポーリングしてください。

Python
client.posts.retrieve(post_id: str) -> APIObject
Python
post = client.posts.retrieve("U29jaWFsUG9zdDo0NDEyMg==")print(post.status)for detail in post.publishDetails:  print(detail.site, detail.submissionError)

posts.delete

投稿を削除し、公開先のすべてのサイトからも削除します。

Python
client.posts.delete(post_id: str) -> APIObject
Python
client.posts.delete("U29jaWFsUG9zdDo0NDEyMg==")

posts.list_for_location

指定した拠点を対象とする投稿キャンペーンの一覧を取得します。オフセット方式のページネーションに対応しており、結果には .records と、totalPages、totalRecords、hasNextPage を含む .pageInfo が含まれます。結果は postsByLocation の配下に返されます。

このルートは tag を拒否するため、SDK は 0.5.3 以降、後方互換性のためにこの引数を受け付けますが、リクエストには一切含めません。タグでフィルタリングする必要がある場合は、posts.bulk_list_for_location を使用してください。

Python
client.posts.list_for_location(    location_id: str | int,    *,    tag: str = "all",    page: int | None = None,    per_page: int | None = None,    filters: dict | None = None,    sort_fields: dict | None = None,) -> APIObject
Python
result = client.posts.list_for_location(16808, page=1, per_page=10)for post in result.records:  print(post.id, post.name)print(result.pageInfo.totalRecords)

posts.bulk_retrieve

一括(複数拠点)キャンペーンを、拠点ごとの公開ステータスおよび分析データとともに取得します。

Python
client.posts.bulk_retrieve(bulk_post_id: str) -> APIObject
Python
bulk = client.posts.bulk_retrieve("QnVsa1Bvc3Q6OTk=")print(bulk.status)

posts.bulk_list_for_location

指定した拠点を含む一括(複数拠点)キャンペーンの一覧を取得します。パラメータと結果の構造は posts.list_for_location と同じです。

Python
client.posts.bulk_list_for_location(    location_id: str | int,    *,    tag: str = "all",    page: int | None = None,    per_page: int | None = None,    filters: dict | None = None,    sort_fields: dict | None = None,) -> APIObject
Python
result = client.posts.bulk_list_for_location(16808, page=1, per_page=10)for campaign in result.records:  print(campaign.id, campaign.name)

関連情報

  • 拠点: 投稿先の拠点を作成・管理します
  • 掲載情報: 拠点ごとの同期ステータスを確認します
  • 分析: Google、Bing、Facebookのプロフィール分析