2

我发现了如何在 iPhone 上使用 FBConnect API 在用户的墙上发送一些文本。我什至找到了如何将图像放在互联网上:

FBFeedDialog* dialog = [[[FBFeedDialog alloc] init] autorelease];
dialog.delegate = self;
dialog.templateBundleId = 12345;
dialog.templateData = @"{\"image\":[{\"src\":\"http://sample.png\",\"href\":\"http://sample.com\"}] }";
[dialog show];

(见http://wiki.developers.facebook.com/index.php/Facebook_Connect_for_iPhone

但我不知道如何使用 FB Api将UIImage从我的 iphone上传到用户的墙上。我是否必须首先将图像上传到任何网站,然后将其 url 放入templateData中?没有更简单的解决方案吗?

谢谢。

马丁

4

2 回答 2

1

使用下面的函数上传图片,将 UIImage 作为参数传递,它将起作用。

- (void)uploadPhoto:(UIImage *)uploadImage
{
    NSMutableDictionary *args = [[[NSMutableDictionary alloc] init] autorelease];
    [args setObject:uploadImage forKey:@"image"];    // 'images' is an array of 'UIImage' objects
    [args setObject:@"4865751097970555873" forKey:@"aid"];// this should be album id
    uploadPhotoRequest = [FBRequest requestWithDelegate:self];
    [uploadPhotoRequest call:@"photos.upload" params:args];

    NSLog(@"uploading image is successful");
}
于 2009-08-29T09:54:21.667 回答
0

[[FBRequest requestWithDelegate:self] call:@"facebook.photos.upload" params:params dataParam:(NSData*)img;

and pass params to nil . it will upload image to default album

于 2010-03-15T13:35:07.130 回答