如何在脸书上发布签到



我需要在Facebook上签到,而不使用Facebook iOS SDK附带的默认签到选项,因为我需要过滤Facebook地点,以便用户只能使用我过滤的地方签到。我已经使用Facebook图形api尝试过这个。

NSDictionary *dict=[NSDictionary dictionaryWithObjectsAndKeys:accsstoken,@"access_token",@"253651184683030",@"place",@"I m here in this place",@"message",@"30.893075018178,75.821777459326",@"coordinates", nil];
[FBRequestConnection startWithGraphPath:@"/me/checkins"
                             parameters:dict
                             HTTPMethod:@"POST"
                      completionHandler:^(
                                          FBRequestConnection *connection,
                                          id result,
                                          NSError *error
                                          ) {
                          NSLog(@"Error...%@",error);
                         }]; 

如果有人知道这件事,请告诉我吗?任何形式的帮助将不胜感激。

这是一个工作代码:

_place.facebookId = 签到地点的地点 ID

listFriends = 用于签到的朋友 ID 列表

-(void)publishToFacebook:(NSString *)message
{
// Create the parameters dictionary that will keep the data that will be posted.
NSMutableArray *fArray = [NSMutableArray new];
for (RCPerson *person in listFriends)
{
    [fArray addObject:person.ID];
}
NSMutableDictionary * params = [NSMutableDictionary new];
if(fArray.count > 0)
{
    params = [NSMutableDictionary dictionaryWithObjectsAndKeys: message, @"message",[fArray componentsJoinedByString:@","], @"tags",  _place.facebookId, @"place", nil];
}
else
{
    params = [NSMutableDictionary dictionaryWithObjectsAndKeys: message, @"message", _place.facebookId, @"place", nil];
}
NSLog(@"params %@", params);
FBRequest *postRequest = [FBRequest requestWithGraphPath:@"me/feed" parameters:params HTTPMethod:@"POST"];
postRequest.session = FBSession.activeSession;
if(![postRequest.session.permissions containsObject:@"publish_stream"])
{
    [postRequest.session requestNewPublishPermissions:@[@"publish_stream", @"publish_actions"] defaultAudience:FBSessionDefaultAudienceEveryone completionHandler:^(FBSession *session, NSError *error) {
        [postRequest startWithCompletionHandler:^(FBRequestConnection *connection, id result, NSError *error) {
            NSLog(@"error %@", error.description);
            if(error)
            {
                dispatch_async(dispatch_get_main_queue(), ^(void) {
                    UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Facebook error" message:[self parseError:error] delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil];
                    [alert show];
                });
            }
            NSLog(@"%@", result);
            //[self checkinMe];
        }];
    }];
}
else
{
    [postRequest startWithCompletionHandler:^(FBRequestConnection *connection, id result, NSError *error) {
        NSLog(@"error %@", error.description);
        if(error)
        {
            dispatch_async(dispatch_get_main_queue(), ^(void) {
                UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Facebook error" message:[self parseError:error] delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil];
                [alert show];
            });
        }
        NSLog(@"%@", result);
        //[self checkinMe];
    }];
}
}

因此,首先,根据Facebook API文档,您尝试执行的操作已被弃用。

你可以在这里阅读它。

现在,您可以使用/{user-id}/feed,只需添加一个位置 ID。 在此处阅读此操作的文档。

至于过滤,不确定这是一个问题。只需根据需要过滤向用户显示的位置列表,并确保仅将其中一个位置作为place传递。

现在已弃用/checkin发布。查看文档 - /checkin

您必须使用Open Graph Actions来做同样的事情,这是关于相同的讨论: facebbok sdk 在像Foursquare这样的帖子中集成交互式地图

最新更新