Graph API 版本

專頁地點

這代表母企業專頁的不同專頁地點。例如,連鎖餐廳的每間餐廳分店專頁。

所有應用程式都可以讀取此關係連線。某些類型的發佈操作僅適用於特定開發人員。

使用此 API 的發佈操作時,請遵循以下守則:

  • 請勿就建立或認領專頁收費。
  • 在允許客戶建立專頁前,請先為其提供認領現有專頁的渠道,以避免發生專頁重複的情況。
  • 確保僅建立與真實實體地址相關的專頁,而非虛假或虛擬地點。
  • 如果您是代表客戶建立專頁,則必須在客戶要求時轉讓專頁的全部管理權。
  • 未經客戶同意,不得向第三方披露專頁的管理員資訊,除非任何適用法律、任何有管轄權的法院或政府機構的任何規則/條例,或法律程式要求披露。

讀取

Graph API 測試工具
GET /v19.0/{page-id}/locations HTTP/1.1
Host: graph.facebook.com
/* PHP SDK v5.0.0 */
/* make the API call */
try {
  // Returns a `Facebook\FacebookResponse` object
  $response = $fb->get(
    '/{page-id}/locations',
    '{access-token}'
  );
} catch(Facebook\Exceptions\FacebookResponseException $e) {
  echo 'Graph returned an error: ' . $e->getMessage();
  exit;
} catch(Facebook\Exceptions\FacebookSDKException $e) {
  echo 'Facebook SDK returned an error: ' . $e->getMessage();
  exit;
}
$graphNode = $response->getGraphNode();
/* handle the result */
/* make the API call */
FB.api(
    "/{page-id}/locations",
    function (response) {
      if (response && !response.error) {
        /* handle the result */
      }
    }
);
/* make the API call */
new GraphRequest(
    AccessToken.getCurrentAccessToken(),
    "/{page-id}/locations",
    null,
    HttpMethod.GET,
    new GraphRequest.Callback() {
        public void onCompleted(GraphResponse response) {
            /* handle the result */
        }
    }
).executeAsync();
/* make the API call */
FBSDKGraphRequest *request = [[FBSDKGraphRequest alloc]
                               initWithGraphPath:@"/{page-id}/locations"
                                      parameters:params
                                      HTTPMethod:@"GET"];
[request startWithCompletionHandler:^(FBSDKGraphRequestConnection *connection,
                                      id result,
                                      NSError *error) {
    // Handle the result
}];

權限

  • 需要任何一個有效的存取憑證才能擷取地點。

欄位

專頁物件陣列,其中每個物件分別代表企業的一個地點。

發佈

您可以在此關係連線上發佈地點,從而將按地點建立的現有專頁加到此名單中:

POST /v19.0/{page-id}/locations HTTP/1.1
Host: graph.facebook.com

main_page_id=%7Bpage-id%7D&store_number=12345&location_page_id=%7Bsubpage-id%7D
/* PHP SDK v5.0.0 */
/* make the API call */
try {
  // Returns a `Facebook\FacebookResponse` object
  $response = $fb->post(
    '/{page-id}/locations',
    array (
      'main_page_id' => '{page-id}',
      'store_number' => '12345',
      'location_page_id' => '{subpage-id}',
    ),
    '{access-token}'
  );
} catch(Facebook\Exceptions\FacebookResponseException $e) {
  echo 'Graph returned an error: ' . $e->getMessage();
  exit;
} catch(Facebook\Exceptions\FacebookSDKException $e) {
  echo 'Facebook SDK returned an error: ' . $e->getMessage();
  exit;
}
$graphNode = $response->getGraphNode();
/* handle the result */
/* make the API call */
FB.api(
    "/{page-id}/locations",
    "POST",
    {
        "main_page_id": "{page-id}",
        "store_number": "12345",
        "location_page_id": "{subpage-id}"
    },
    function (response) {
      if (response && !response.error) {
        /* handle the result */
      }
    }
);
Bundle params = new Bundle();
params.putString("main_page_id", "{page-id}");
params.putString("store_number", "12345");
params.putString("location_page_id", "{subpage-id}");
/* make the API call */
new GraphRequest(
    AccessToken.getCurrentAccessToken(),
    "/{page-id}/locations",
    params,
    HttpMethod.POST,
    new GraphRequest.Callback() {
        public void onCompleted(GraphResponse response) {
            /* handle the result */
        }
    }
).executeAsync();
NSDictionary *params = @{
  @"main_page_id": @"{page-id}",
  @"store_number": @"12345",
  @"location_page_id": @"{subpage-id}",
};
/* make the API call */
FBSDKGraphRequest *request = [[FBSDKGraphRequest alloc]
                               initWithGraphPath:@"/{page-id}/locations"
                                      parameters:params
                                      HTTPMethod:@"POST"];
[request startWithCompletionHandler:^(FBSDKGraphRequestConnection *connection,
                                      id result,
                                      NSError *error) {
    // Handle the result
}];

權限

  • 需要使用專頁存取憑證,才能將現有地點發佈到專頁。
  • 需要使用專頁存取憑證,才能建立新地點並將其加到專頁。只有特定開發人員有權使用此功能。

欄位

名稱說明類型

differently_open_offerings

temporary_status 設定為 differently_open 時使用,用於標示企業的營運方式與平常有何不同,例如餐廳提供外賣服務。列舉鍵值可能為以下一項或多項:ONLINE_SERVICESDELIVERYPICKUPOTHER,其值設定為 truefalse。例如,提供外賣自取服務但暫停外賣送餐的餐廳將為 differently_open_offerings:{"DELIVERY":"false", "PICKUP":"true"}

object

hours

定義此地點的營業時間。

object

{day}_{number}_{status}

定義一天當中的單個營業時段。每天可以有 2 個不同的時段。{day} 是星期中的日子的前 3 個字元;{number} 則必須是 12,以辨別每一天的兩個不同時段;{status} 應為 openclose,以區隔時間範圍的開始或結束。例如,含數值 17:00mon_1_open 和含數值 21:15mon_1_close,分別代表星期一下午 5 點至晚上 9:15 的單一營業時段。

string

ignore_warnings

指定是否停用此 API 調用產生的任何警告(並非錯誤),例如緯度和經度與街道地址不符。

bool

is_franchise

這是否為特許經營地點?

bool

country

國家/地區名稱。如果未包含 city_id,則此為必要欄位。

string

city

城市名稱。如果未包含 city_id,則此為必要欄位。

string

city_id

城市編號。這是 adcity 目標指定選項key 值。如果未包含此值,則 citycountry 為必要欄位(如果是美國的地點,則 statezip 亦為必要欄位)。

int

latitude

以小數表示的維度。此為 location 的必要欄位。

string

location

此欄位定義了此專頁的地點。如果未指定 location_page_id,則此為必要欄位。字典必須包含 street 鍵值(街道地址),亦須包含 city_idcitystatecountry 全部欄位(如果地址不在美國,則 state 為選用欄位)。除非是美國地址,否則 zip 欄位亦為選用欄位。請參閱本文件之後的部分,了解有關產生城市編號的資訊。

object

longitude

以小數表示的經度。此為 location 的必要欄位。

string

state

州/省(或當地相應行政區劃單位)名稱。

string

street

街道地址。此為 location 的必要欄位。

string

zip

地點的郵遞區號(或當地相應項目)。

string

location_page_id

您要新增為地點的 Facebook 專頁編號。如果未包含此欄位,則必須另外指定 locationplace_topicsphone 欄位,以建立新的地點專頁。

numeric string

main_page_id

所有地點的母地點 Facebook 專頁編號。此為必要欄位。

numeric string

permanently_closed

此地點是否已永久關閉?

bool

phone

此地點的電話號碼。如果未指定 location_page_id,則此為必要欄位。

string

pickup_options

適用於此地點的自取選項清單。

enum[] {CURBSIDE, IN_STORE, OTHER}

place_topics

此地點的地點主題。如果未指定 location_page_id,則此為必要欄位。

int[]

store_number

開發人員為此地點定義的可變編號,通常用於連結回地點的內部資料庫。此為必要欄位。

int

temporary_status

標示專頁相應企業的營運方式與平常有何不同。如果此欄位設定為 differently_open,請連同 differently_open_offerings 使用以設定狀態。

列舉 {differently_open, temporarily_closed, operating_as_usual, no_data}

回應

成功後,應用程式會收到以下內容:

{
  "success": true
}

否則系統會傳回相關的錯誤訊息。

刪除

您可以刪除此關係連線,從地點的母清單中移除地點專頁:

DELETE /v19.0/{page-id}/locations HTTP/1.1
Host: graph.facebook.com

main_page_id=%7Bpage-id%7D&store_number=12345&location_page_id=%7Bsubpage-id%7D
/* PHP SDK v5.0.0 */
/* make the API call */
try {
  // Returns a `Facebook\FacebookResponse` object
  $response = $fb->delete(
    '/{page-id}/locations',
    array (
      'main_page_id' => '{page-id}',
      'store_number' => '12345',
      'location_page_id' => '{subpage-id}',
    ),
    '{access-token}'
  );
} catch(Facebook\Exceptions\FacebookResponseException $e) {
  echo 'Graph returned an error: ' . $e->getMessage();
  exit;
} catch(Facebook\Exceptions\FacebookSDKException $e) {
  echo 'Facebook SDK returned an error: ' . $e->getMessage();
  exit;
}
$graphNode = $response->getGraphNode();
/* handle the result */
/* make the API call */
FB.api(
    "/{page-id}/locations",
    "DELETE",
    {
        "main_page_id": "{page-id}",
        "store_number": "12345",
        "location_page_id": "{subpage-id}"
    },
    function (response) {
      if (response && !response.error) {
        /* handle the result */
      }
    }
);
Bundle params = new Bundle();
params.putString("main_page_id", "{page-id}");
params.putString("store_number", "12345");
params.putString("location_page_id", "{subpage-id}");
/* make the API call */
new GraphRequest(
    AccessToken.getCurrentAccessToken(),
    "/{page-id}/locations",
    params,
    HttpMethod.DELETE,
    new GraphRequest.Callback() {
        public void onCompleted(GraphResponse response) {
            /* handle the result */
        }
    }
).executeAsync();
NSDictionary *params = @{
  @"main_page_id": @"{page-id}",
  @"store_number": @"12345",
  @"location_page_id": @"{subpage-id}",
};
/* make the API call */
FBSDKGraphRequest *request = [[FBSDKGraphRequest alloc]
                               initWithGraphPath:@"/{page-id}/locations"
                                      parameters:params
                                      HTTPMethod:@"DELETE"];
[request startWithCompletionHandler:^(FBSDKGraphRequestConnection *connection,
                                      id result,
                                      NSError *error) {
    // Handle the result
}];

權限

  • 必須使用專頁存取憑證,才能從母專頁中移除地點。

欄位

所有欄位均為必填欄位。

名稱 說明 類型

main_page_id

此地點的主 Facebook 專頁編號。

numeric string

store_number

開發人員為此地點定義的編號。

numeric string

location_page_id

Facebook 為此地點定義的編號。

numeric string

回應

如果成功:

{
  "success": true
}

否則系統會傳回相關的錯誤訊息。

更新

新版專頁體驗支援此端點。

POST /v19.0/{page-id}/locations HTTP/1.1
Host: graph.facebook.com

main_page_id=%7Bpage-id%7D&store_number=12345&location_page_id=%7Bsubpage-id%7D
/* PHP SDK v5.0.0 */
/* make the API call */
try {
  // Returns a `Facebook\FacebookResponse` object
  $response = $fb->post(
    '/{page-id}/locations',
    array (
      'main_page_id' => '{page-id}',
      'store_number' => '12345',
      'location_page_id' => '{subpage-id}',
    ),
    '{access-token}'
  );
} catch(Facebook\Exceptions\FacebookResponseException $e) {
  echo 'Graph returned an error: ' . $e->getMessage();
  exit;
} catch(Facebook\Exceptions\FacebookSDKException $e) {
  echo 'Facebook SDK returned an error: ' . $e->getMessage();
  exit;
}
$graphNode = $response->getGraphNode();
/* handle the result */
/* make the API call */
FB.api(
    "/{page-id}/locations",
    "POST",
    {
        "main_page_id": "{page-id}",
        "store_number": "12345",
        "location_page_id": "{subpage-id}"
    },
    function (response) {
      if (response && !response.error) {
        /* handle the result */
      }
    }
);
Bundle params = new Bundle();
params.putString("main_page_id", "{page-id}");
params.putString("store_number", "12345");
params.putString("location_page_id", "{subpage-id}");
/* make the API call */
new GraphRequest(
    AccessToken.getCurrentAccessToken(),
    "/{page-id}/locations",
    params,
    HttpMethod.POST,
    new GraphRequest.Callback() {
        public void onCompleted(GraphResponse response) {
            /* handle the result */
        }
    }
).executeAsync();
NSDictionary *params = @{
  @"main_page_id": @"{page-id}",
  @"store_number": @"12345",
  @"location_page_id": @"{subpage-id}",
};
/* make the API call */
FBSDKGraphRequest *request = [[FBSDKGraphRequest alloc]
                               initWithGraphPath:@"/{page-id}/locations"
                                      parameters:params
                                      HTTPMethod:@"POST"];
[request startWithCompletionHandler:^(FBSDKGraphRequestConnection *connection,
                                      id result,
                                      NSError *error) {
    // Handle the result
}];

權限

  • 必須使用專頁存取憑證,才能在母專頁更新地點。

欄位

如要更新,請加入任何必填發佈欄位,以及您要更改其值的任何其他發佈欄位

回應

如果成功:

{
  "success": true
}

否則系統會傳回相關的錯誤訊息。