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 關係連線為粉絲專頁安裝應用程式。 名稱 | 說明 | 類型 |
---|---|---|
| 指示此訂閱套用的物件類型。 |
|
| 觸發更新時會收到 |
|
| 要在此 |
|
| 顯示變更通知是否應包含新值。 |
|
| 可用來向伺服器確認要求有效的任意字串。 |
|
如果回呼網址有效且訂閱成功,就會出現以下內容:
{ "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 }
否則會傳回相關錯誤訊息。
若要在此關係連線上執行更新作業,請使用新值進行發佈操作。如此一來,系統就會直接修改指定主題的訂閱,而不會覆寫現有欄位。