• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

ios - 如何在 Facebook 上发布签到?

[复制链接]
菜鸟教程小白 发表于 2022-12-12 09:14:21 | 显示全部楼层 |阅读模式 打印 上一主题 下一主题

我需要在 Facebook 上签到,而不使用 Facebook iOS SDK 附带的默认签到选项,因为我需要过滤 Facebook 地点,以便用户只能使用我过滤的地点签到。 我已经使用 Facebook graph 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"OST"
                      completionHandler:^(
                                          FBRequestConnection *connection,
                                          id result,
                                          NSError *error
                                          ) {
                          NSLog(@"Error...%@",error);

                         }]; 

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



Best Answer-推荐答案


这是一个工作代码:

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

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

-(void)publishToFacebookNSString *)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"OST"];
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];

    }];
}

}

关于ios - 如何在 Facebook 上发布签到?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22904285/

回复

使用道具 举报

懒得打字嘛,点击右侧快捷回复 【右侧内容,后台自定义】
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

关注0

粉丝2

帖子830918

发布主题
阅读排行 更多
广告位

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap