【问题标题】:Error:posting image on facebook using FBConnect错误:使用 FBConnect 在 facebook 上发布图像
【发布时间】:2012-12-10 14:26:28
【问题描述】:

我正在使用 FBConnect 在 facebook 上发布图片。我的代码如下:

- (void) postOnPage
{
    [self saveAccessTokenKeyInfo];

    //post image on wall

    UIImage *img = [UIImage imageNamed:@"image1.png"];
    NSData *data = UIImagePNGRepresentation(img);

    NSMutableDictionary *params = [NSMutableDictionary dictionaryWithObjectsAndKeys:
                                   @"My hat image", @"message", data, @"source", nil];

    [facebook requestWithGraphPath:@"/me/photos" andParams:params andHttpMethod:@"POST" andDelegate:self];

}

-(void)request:(FBRequest *)request didFailWithError:(NSError *)error{
    NSLog(@"%@", [error localizedDescription]);
    NSLog(@"Err details: %@", [error description]);

    // Stop the activity just in case there is a failure and the activity view is animating.

}

我的控制台打印以下错误日志

The operation couldn’t be completed. (facebookErrDomain error 10000.)
2012-12-10 19:53:56.153 HatApplication[5724:c07] Err details: Error Domain=facebookErrDomain Code=10000 "The operation couldn’t be completed. (facebookErrDomain error 10000.)" UserInfo=0x7fc4da0 {error=<CFBasicHash 0x7fc1120 [0x1b57b48]>{type = mutable dict, count = 3,
entries =>
    2 : <CFString 0x7fc0930 [0x1b57b48]>{contents = "type"} = <CFString 0x7fc30f0 [0x1b57b48]>{contents = "OAuthException"}
    3 : <CFString 0x7fc0d10 [0x1b57b48]>{contents = "message"} = <CFString 0x7fc0cf0 [0x1b57b48]>{contents = "An active access token must be used to query information about the current user."}
    6 : <CFString 0x7f76390 [0x1b57b48]>{contents = "code"} = 2500
}
}

我的代码中缺少什么?

【问题讨论】:

    标签: iphone ios facebook fbconnect


    【解决方案1】:

    在您的方法中尝试以下几行:

    [self saveAccessTokenKeyInfo];
    NSString *filePath = [[NSBundle mainBundle] pathForResource:@"image1" ofType:@"png"];
    NSData *videoData = [NSData dataWithContentsOfFile:filePath];
    NSMutableDictionary *params = [NSMutableDictionary dictionaryWithObjectsAndKeys:
                                       @"My hat image", @"message", data, @"source", nil];
    
    [facebook requestWithGraphPath:@"/me/photos" andParams:params andHttpMethod:@"POST" andDelegate:self];
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-09-07
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多