这里我有一个应用程序,其逻辑如下:
user_likes
权限登录并使用Graph API调用/me/likes/{facebook_page_id}/
根据某人是否喜欢某个网页,对您的应用或应用内的某些内容进行门禁访问。
但是使用FBSDKLikeButton
或FBSDKLikeControl
时,没有回调/委托知道我是否可以继续执行第2步。
我的问题是:有没有解决方法?
我正在开发iOS和Android App。以下是iOS相关部分的代码:
FBSDKGraphRequest *request = [[FBSDKGraphRequest alloc]
initWithGraphPath:@"/me/likes/19292868552/"
parameters:@{@"fields": @"id"}
HTTPMethod:@"GET"];
[request startWithCompletionHandler:^(FBSDKGraphRequestConnection *connection,
id result,
NSError *error) {
if(error) {
// notify there is error
} else {
NSArray *likedID = [[result valueForKey:@"data"] valueForKey:@"id"];
if(likedID != nil && likedID.count > 0) {
// Liked, get coupon
} else {
// Not liked yet, show like button
likeButton = [[FBSDKLikeButton alloc] init];
likeButton.objectID = [NSString stringWithFormat:@"https://www.facebook.com/FacebookDevelopers?rand=%d", rand()];
likeButton.objectType = FBSDKLikeObjectTypePage;
[likeButton addTarget:self action:@selector(likeFBclick:) forControlEvents:UIControlEventTouchUpInside];
[self.view addSubview:likeButton];
}
}
}];
其中likeFBclick:
只是转发用户获取优惠券。