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 }
否则系统会返回相关的错误消息。
您可以使用新值执行发布操作,在此连线上执行更新。如此便可在不覆盖现有字段的情况下,修改特定主题的订阅。