我有以下代码来添加一个事件,一切正常并加载到 facebook,没有任何问题,唯一的问题是图像没有上传,iOS 文档中也没有任何类型的帮助,也许我正在寻找错误的地方?也许您经历过这种情况并且可以提供帮助。谢谢
NSMutableDictionary *params = [NSMutableDictionary dictionaryWithObjectsAndKeys:
[delegate facebook].accessToken, @"access_token",
@"Going To Eat!", @"name",
@"description of the event", @"description",
@"2012-08-20T17:00:00+0000", @"start_time",
@"2012-08-21T17:00:00+0000", @"end_time",
@"Carlsbad", @"city",
@"CA", @"state",
@"900 safe street", @"street",
@"OPEN", @"privacy",
@"https://.../img/faces/pizza-port-brewing-carlsbad.jpg", @"@file.jpg",
nil];
[[delegate facebook] requestWithGraphPath:@"me/events"
andParams:params
andHttpMethod:@"POST"
andDelegate:self];
最佳答案
好吧,如果您使用当前的 iOS 版 Facebook API,那么您可以将 UIImage 对象传递给 requestWithGraphPath:调用它会自动检测它并将其上传到您的事件图标。如果它是图像链接,则从 NSURL 中创建 UIImage。
UIImage *image = [[UIImage alloc]initWithImageNamed@"test.png"];
NSMutableDictionary *params = [NSMutableDictionary dictionaryWithObjectsAndKeys:
[delegate facebook].accessToken, @"access_token",
@"Going To Eat!", @"name",
@"description of the event", @"description",
@"2012-08-20T17:00:00+0000", @"start_time",
@"2012-08-21T17:00:00+0000", @"end_time",
@"Carlsbad", @"city",
@"CA", @"state",
@"900 safe street", @"street",
@"OPEN", @"privacy",
image, @"picture",
nil];
[[delegate facebook] requestWithGraphPath:@"me/events"
andParams:params
andHttpMethod:@"POST"
andDelegate:self];
关于ios - iphone - 如何在使用 Facebook IOS SDK 创建事件时添加图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11534363/