圖形 API 版本

粉絲專頁地點

這代表主要商家粉絲專頁的不同粉絲專頁地點。例如,連鎖餐廳旗下每家餐廳的粉絲專頁。

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

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

  • 不得針對建立或認領粉絲專頁收取費用。
  • 在用戶端開始建立粉絲專頁前,必須先提供認領現有地標的方法,以避免重複建立粉絲專頁。
  • 請確認僅建立與真實地址相關聯的粉絲專頁,而不是偽造或虛擬地標。
  • 如果您代表用戶端建立粉絲專頁,必須根據用戶端的要求轉移該粉絲專頁的完全管理權。
  • 未經用戶端同意,請勿向第三方透露粉絲專頁的管理員,除非任何適用法律、任何具有充分管轄權之法院或政府機構的任何規則或法規,或依據法律程序提出要求。

讀取

圖形 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 以劃定時間範圍的開始或結束。舉例來說,mon_1_open 的值為 17:00mon_1_close 的值為 21:15,代表每星期一從下午 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_id 或所有 citystatecountry(但如果地址不在美國,則 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 來設定狀態。

enum {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
}

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