CARVIEW |

Reading
GET /v23.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
}];
Permissions
- An app access token is required to return subscriptions for that app.
Fields
Name | Description | Type |
---|---|---|
| Indicates the object type that this subscription applies to. |
|
| The URL that will receive the |
|
| The set of fields in this |
|
| Indicates whether or not the subscription is active. |
|
Creating
You can create new Webhooks subscriptions using this edge:
POST /v23.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' => 'https://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", "https://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": @"https://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
}];
Making a POST request with the callback_url
, verify_token
, and object
fields will reactivate the subscription.
Limitations
- Webhooks for Instagram is not supported. Instagram webhooks must be configured using the App Dashboard.
- Webhooks for WhatsApp is not supported. WhatsApp webhooks must be configured using the App Dashboard.
Permissions
- An app access token is required to add new subscriptions for that app.
- Subscriptions for the object type
user
will only be valid for users who have installed the app. - Subscriptions for the object type
page
will only be valid for Pages that have installed the app. You can install the app for a Page using the /{page-id}/subscribed_apps edge. - The app used to subscribe should be set up to receive Webhooks updates.
Fields
Name | Description | Type |
---|---|---|
| Indicates the object type that this subscription applies to. |
|
| The URL that will receive the |
|
| One or more of the set of valid fields in this |
|
| Indicates if change notifications should include the new values. |
|
| An arbitrary string that can be used to confirm to your server that the request is valid. |
|
Response
If your callback URL is valid and the subscription is successful:
{ "success": true }
Otherwise a relevant error message will be returned.
Deleting
You can delete all or per-object subscriptions using this operation:
DELETE /v23.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
}];
You can delete specific fields from your subscription by including a fields
param.
Permissions
- An app access token is required to delete subscriptions for that app.
Fields
Name | Description | Type |
---|---|---|
| A specific object type to remove subscriptions for. If this optional field is not included, all subscriptions for this app will be removed. |
|
| One or more of the set of valid fields in this |
|
Response
If successful:
{ "success": true }
Otherwise a relevant error message will be returned.
Updating
You can perform updates on this edge by performing a publish operation with new values. This will amend the susbcription for the given topic without overwriting existing fields.