使用 iPhone 应用程序将照片上传到 Facebook 时出现错误
我在 iPhone 应用程序中使用 facebook connect 将照片上传到 facebook 时遇到问题。我尝试过从 facebook SDK 下载的演示应用程序。他们用来上传照片的代码如下:
- (IBAction)uploadPhoto:(id)sender {
NSString *path = @"http://www.facebook.com/images/devsite/iphone_connect_btn.jpg";
NSURL *url = [NSURL URLWithString:path];
NSData *data = [NSData dataWithContentsOfURL:url];
UIImage *img = [[UIImage alloc] initWithData:data];
NSMutableDictionary * params = [NSMutableDictionary dictionaryWithObjectsAndKeys:
img, @"picture",
nil];
[_facebook requestWithMethodName: @"photos.upload"
andParams: params
andHttpMethod: @"POST"
andDelegate: self];
[img release];
}
但是,使用这种方法并没有上传照片。我已使用 [_facebook dial:@"stream.publish" andParams:params andDelegate:self]
成功发布到用户墙上,但从未成功发布照片。它总是给我这个错误:
"The operation couldn’t be completed. (facebookErrDomain error 101.)" UserInfo=0x4d80be0 {request_args=(
{
key = method;
value = "photos.upload";
},
{
key = sdk;
value = ios;
},
{
key = "sdk_version";
value = 2;
},
{
key = format;
value = json;
}
), error_msg=Invalid API key, error_code=101}
尝试了谷歌搜索建议的大量可能的方法,但没有运气。如果有人能阐明这一点,我将不胜感激。提前致谢。
I'm experiencing problem using facebook connect to upload photos to facebook in my iPhone app. I've tried the demo app downloaded from facebook SDK. The code they use to upload photos is as follows:
- (IBAction)uploadPhoto:(id)sender {
NSString *path = @"http://www.facebook.com/images/devsite/iphone_connect_btn.jpg";
NSURL *url = [NSURL URLWithString:path];
NSData *data = [NSData dataWithContentsOfURL:url];
UIImage *img = [[UIImage alloc] initWithData:data];
NSMutableDictionary * params = [NSMutableDictionary dictionaryWithObjectsAndKeys:
img, @"picture",
nil];
[_facebook requestWithMethodName: @"photos.upload"
andParams: params
andHttpMethod: @"POST"
andDelegate: self];
[img release];
}
However, no photo is uploaded using this method. I've successfully post to a user's wall using [_facebook dialog:@"stream.publish" andParams:params andDelegate:self]
but never succeeded to post photos. It always give me this error:
"The operation couldn’t be completed. (facebookErrDomain error 101.)" UserInfo=0x4d80be0 {request_args=(
{
key = method;
value = "photos.upload";
},
{
key = sdk;
value = ios;
},
{
key = "sdk_version";
value = 2;
},
{
key = format;
value = json;
}
), error_msg=Invalid API key, error_code=101}
Tried tonnes of possible method suggested by google search but with no luck. Grateful if anyone can shed some light on this. Thanks in advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以尝试如下代码:
You can try the Code as below:
您是否在权限中指定了@“publish_stream”(在“initWithNibname”方法中)?
Did you specify @"publish_stream" in the permsissions (in the 'initWithNibname' method) ?