使用Facebook IOS SDK 3.1和Graph API发布带有标题的图像

时间:2012-12-27 08:40:23

标签: ios facebook facebook-graph-api facebook-ios-sdk

我是facebook SDK的新手。 上次我使用facebook IOS SDK 3.0并通过图形API发布图像。它正在发挥作用,但现在却不行。我升级到3.1但仍然会返回HTTP ERROR 200.有没有人可以帮助我?

这是代码

- (void) facebookPostPhoto:(UIImage *)photo withMessage:(NSString *)msg withOkAction:(SEL)okAction andNGAction:(SEL)ngAction withTarget:(id)target {
ok = okAction;
ng = ngAction;
curView = target;
NSMutableDictionary *params;
params = [NSMutableDictionary dictionaryWithObjectsAndKeys:
          UIImageJPEGRepresentation(photo, 90), @"source",
          msg, @"message",             
          nil];

if ([FBSession.activeSession.permissions indexOfObject:FacebookPermission_3] == NSNotFound) {
    NSLog(@"permission not found");
    // No permissions found in session, ask for it
    [FBSession.activeSession reauthorizeWithPublishPermissions:[NSArray arrayWithObjects:FacebookPermission_1, FacebookPermission_3, nil] defaultAudience:FBSessionDefaultAudienceFriends completionHandler:^(FBSession *session, NSError *error)
     {
         // If permissions granted, publish the story
         if (!error) [self initPostFacebookWithParams:params];
     }];
} else {
    [self initPostFacebookWithParams:params];
} } 

- (void)initPostFacebookWithParams:(NSMutableDictionary *)params {

[FBRequestConnection startWithGraphPath:@"me/photos" parameters:params HTTPMethod:@"POST" completionHandler:^(FBRequestConnection *connection, id result, NSError *error) {
    NSLog(@"ERROR : %@", error.localizedDescription);
    if (!error) {
        NSLog(@"Facebook Post Success..");
        if (ok && curView) {
            [curView performSelector:ok];
        }


    } else {
        NSLog(@"Facebook Post Failed..");
        if (ng && curView) {
            [curView performSelector:ng withObject:error];
        }

    }

}]; }

感谢您的快速反应和帮助!谢谢!!

1 个答案:

答案 0 :(得分:0)

我认为这是Facebook上传的服务器已关闭或有关于图像大小的新政策。当我将图像缩小到320x320时,它不会返回任何错误,顺便说一下也会出现错误。

因此,对于那些看到此问题的人,请尝试将图片调整为较小的尺寸。