그래프 API 버전

/{app-id}/subscriptions

이 에지를 사용하여 앱에서 Webhooks 구독을 구성할 수 있습니다.

읽기

그래프 API 탐색기
GET /v19.0/{app-id}/subscriptions 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(
    '/{app-id}/subscriptions',
    '{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 */
new GraphRequest(
    AccessToken.getCurrentAccessToken(),
    "/{app-id}/subscriptions",
    null,
    HttpMethod.GET,
    new GraphRequest.Callback() {
        public void onCompleted(GraphResponse response) {
            /* handle the result */
        }
    }
).executeAsync();
/* make the API call */
FBSDKGraphRequest *request = [[FBSDKGraphRequest alloc]
                               initWithGraphPath:@"/{app-id}/subscriptions"
                                      parameters:params
                                      HTTPMethod:@"GET"];
[request startWithCompletionHandler:^(FBSDKGraphRequestConnection *connection,
                                      id result,
                                      NSError *error) {
    // Handle the result
}];

권한

  • 해당 앱에 대한 구독을 반환하려면 앱 액세스 토큰이 필요합니다.

필드

이름 설명 유형

object

이 구독에 적용되는 개체 유형을 나타냅니다.

enum{user, page, permissions, payments}

callback_url

업데이트를 트리거할 때 POST 요청을 수신할 URL입니다.

string

fields

구독하고 있는 이 object필드 세트입니다.

string[]

active

구독이 활성 상태인지 여부를 나타냅니다.

bool

만들기

이 에지를 사용하여 새로운 Webhooks 구독을 만들 수 있습니다.

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

object=page&callback_url=http%3A%2F%2Fexample.com%2Fcallback%2F&fields=about%2C+picture&include_values=true&verify_token=thisisaverifystring
/* PHP SDK v5.0.0 */
/* make the API call */
try {
  // Returns a `Facebook\FacebookResponse` object
  $response = $fb->post(
    '/{app-id}/subscriptions',
    array (
      'object' => 'page',
      'callback_url' => 'http://example.com/callback/',
      'fields' => 'about, picture',
      'include_values' => 'true',
      'verify_token' => 'thisisaverifystring',
    ),
    '{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 */
Bundle params = new Bundle();
params.putString("object", "page");
params.putString("callback_url", "http://example.com/callback/");
params.putString("fields", "about, picture");
params.putString("include_values", "true");
params.putString("verify_token", "thisisaverifystring");
/* make the API call */
new GraphRequest(
    AccessToken.getCurrentAccessToken(),
    "/{app-id}/subscriptions",
    params,
    HttpMethod.POST,
    new GraphRequest.Callback() {
        public void onCompleted(GraphResponse response) {
            /* handle the result */
        }
    }
).executeAsync();
NSDictionary *params = @{
  @"object": @"page",
  @"callback_url": @"http://example.com/callback/",
  @"fields": @"about, picture",
  @"include_values": @"true",
  @"verify_token": @"thisisaverifystring",
};
/* make the API call */
FBSDKGraphRequest *request = [[FBSDKGraphRequest alloc]
                               initWithGraphPath:@"/{app-id}/subscriptions"
                                      parameters:params
                                      HTTPMethod:@"POST"];
[request startWithCompletionHandler:^(FBSDKGraphRequestConnection *connection,
                                      id result,
                                      NSError *error) {
    // Handle the result
}];

callback_url, verify_tokenobject 필드로 POST 요청을 보내면 구독이 다시 활성화됩니다.

제한 사항

  • Instagram용 Webhooks는 지원되지 않습니다. Instagram Webhooks는 앱 대시보드를 사용하여 구성해야 합니다.
  • WhatsApp용 Webhooks는 지원되지 않습니다. WhatsApp Webhooks는 앱 대시보드를 사용하여 구성해야 합니다.

권한

  • 해당 앱에 대한 새로운 구독을 추가하려면 앱 액세스 토큰이 필요합니다.
  • user 개체 유형에 대한 구독은 앱을 설치한 사용자에게만 유효합니다.
  • page 개체 유형에 대한 구독은 앱을 설치한 페이지에만 유효합니다. /{page-id}/subscribed_apps 에지를 사용하여 페이지에 대해 앱을 설치할 수 있습니다.
  • 구독에 사용되는 앱은 Webhooks 업데이트를 수신하도록 설정해야 합니다.

필드

이름 설명 유형

object

이 구독에 적용되는 개체 유형을 나타냅니다.

enum{user, page, permissions, payments}

callback_url

업데이트가 트리거될 때 POST 요청을 수신하고, 이 게시 작업을 시도할 때 GET 요청을 수신할 URL입니다. 콜백 URL 페이지 구성 가이드를 참조하세요.

string

fields

구독할 이 object에 있는 하나 이상의 유효한 필드 세트입니다.

string[]

include_values

변경 사항 알림에 새 값이 포함되어야 하는지 여부를 나타냅니다.

bool

verify_token

요청이 유효한지 서버에 확인하는 데 사용할 수 있는 임의의 문자열입니다.

string

응답

콜백 URL이 유효하고 구독이 성공한 경우:

{
  "success": true
}

실패할 경우 관련 오류 메시지가 반환됩니다.

삭제

이 작업을 사용하여 모든 구독 또는 개체별 구독을 삭제할 수 있습니다.

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

object=page
/* PHP SDK v5.0.0 */
/* make the API call */
try {
  // Returns a `Facebook\FacebookResponse` object
  $response = $fb->delete(
    '/{app-id}/subscriptions',
    array (
      'object' => 'page',
    ),
    '{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 */
Bundle params = new Bundle();
params.putString("object", "page");
/* make the API call */
new GraphRequest(
    AccessToken.getCurrentAccessToken(),
    "/{app-id}/subscriptions",
    params,
    HttpMethod.DELETE,
    new GraphRequest.Callback() {
        public void onCompleted(GraphResponse response) {
            /* handle the result */
        }
    }
).executeAsync();
NSDictionary *params = @{
  @"object": @"page",
};
/* make the API call */
FBSDKGraphRequest *request = [[FBSDKGraphRequest alloc]
                               initWithGraphPath:@"/{app-id}/subscriptions"
                                      parameters:params
                                      HTTPMethod:@"DELETE"];
[request startWithCompletionHandler:^(FBSDKGraphRequestConnection *connection,
                                      id result,
                                      NSError *error) {
    // Handle the result
}];

fields 매개변수를 포함하여 구독에서 특정 필드를 삭제할 수 있습니다.

권한

  • 해당 앱에 대한 구독을 삭제하려면 앱 액세스 토큰이 필요합니다.

필드

이름 설명 유형

object

구독을 삭제할 특정 개체 유형입니다. 이 선택적 필드를 포함하지 않을 경우 이 앱에 대한 모든 구독이 삭제됩니다.

enum{user, page, permissions, payments}

fields

구독할 이 object에 있는 하나 이상의 유효한 필드 세트입니다.

string[]

응답

성공한 경우:

{
  "success": true
}

실패할 경우 관련 오류 메시지가 반환됩니다.

업데이트

새 값으로 게시 작업을 수행하여 이 에지에 대한 업데이트를 수행할 수 있습니다. 그러면 기존 필드를 덮어쓰지 않고도 특정 주제에 대한 구독을 수정할 수 있습니다.