图谱 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}

定义一天当中的单个营业时间段。每天可以有两个不同的时间段。{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_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 一起用于状态设置。

枚举 {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
}

否则系统会返回相关的错误消息。