GET /v21.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
}];
名稱 | 說明 | 類型 |
---|---|---|
| 表明此訂閱適用的物件類型。 |
|
| 會在觸發更新時收到 |
|
| 此 |
|
| 表明訂閱是否正常運行中。 |
|
您可以使用此關係連線建立新的 Webhooks 訂閱:
POST /v21.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_token
和 object
欄位的 POST 要求後,訂閱會重新啟用。
user
的訂閱僅適用於已安裝應用程式的用戶。page
的訂閱僅適用於已安裝應用程式的專頁。您可以使用 /{page-id}/subscribed_apps edge 為專頁安裝應用程式。 名稱 | 說明 | 類型 |
---|---|---|
| 表明此訂閱適用的物件類型。 |
|
| 在觸發更新時接收 |
|
| 此 |
|
| 表明變更通知是否應包含新值。 |
|
| 用於向伺服器確認要求是否有效的任意字串。 |
|
如果您的回呼網址有效,並且訂閱成功:
{ "success": true }
否則系統會傳回相關的錯誤訊息。
您可以使用以下操作刪除所有或每個物件的訂閱:
DELETE /v21.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
參數,從訂閱中刪除特定欄位。
名稱 | 說明 | 類型 |
---|---|---|
| 要移除訂閱的特定物件類型。如果未加入此可選欄位,則此應用程式的所有訂閱都將被移除。 |
|
| 此 |
|
如果成功:
{ "success": true }
否則系統會傳回相關的錯誤訊息。
您可以使用新值執行發佈操作,在此關係連線上執行更新。這樣將可修訂既定主題的訂閱,而不覆寫現有欄位。