使用新的iOS Facebook SDK API(3.0)上传照片 [英] Upload photo using new iOS Facebook SDK API (3.0)

查看:118
本文介绍了使用新的iOS Facebook SDK API(3.0)上传照片的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何使用新的API / SDK从iOS应用上传照片到Facebook?我已经尝试了,我没有到任何地方,只是继续跑在圈子里。这是我现在的代码:

How can I upload a photo to facebook from an iOS app using their new API/SDK? I've already tried and I'm not getting anywhere, just keep running in circles. Here is the code I currently have:

-(void)dataForFaceboo{
    self.postParams =
    [[NSMutableDictionary alloc] initWithObjectsAndKeys:
     self.uploadPhoto.image, @"picture", nil];
}

-(void)uploadToFacebook{

    [self dataForFacebook];

    NSLog(@"Going to facebook: %@", self.postParams);

    // Hide keyboard if showing when button clicked
    if ([self.photoCaption isFirstResponder]) {
        [self.photoCaption resignFirstResponder];
    }
    // Add user message parameter if user filled it in
    if (![self.photoCaption.text
        isEqualToString:kPlaceholderPostMessage] &&
        ![self.photoCaption.text isEqualToString:@""]) 
    {
        [self.postParams setObject:self.photoCaption.text forKey:@"message"];
    }
    [FBRequestConnection startWithGraphPath:@"me/feed"
        parameters:self.postParams
        HTTPMethod:@"POST"
        completionHandler:^(FBRequestConnection *connection,
                            id result,
                            NSError *error) 
    {
        NSString *alertText;
        if (error) {
            alertText = [NSString stringWithFormat:
                         @"error: domain = %@, code = %d",
                      error.domain, error.code];
        } else {
            alertText = [NSString stringWithFormat:
                         @"Posted action, id: %@",
                         [result objectForKey:@"id"]];
        }
        // Show the result in an alert
        [[[UIAlertView alloc] initWithTitle:@"Result"
                              message:alertText
                              delegate:self
                              cancelButtonTitle:@"OK!"
                              otherButtonTitles:nil] show];
    }];
}


推荐答案

我/照片是意味着照片实际上在您的Facebook个人资料的照片列表。 我/饲料只是时间轴上的一个职位。

"me/photos" is meant for the photo actually be in the "Photo's" list on your Facebook profile. "me/feed" is just a post on the timeline.

这篇关于使用新的iOS Facebook SDK API(3.0)上传照片的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆