Iphone 将照片发布到Facebook

Iphone 将照片发布到Facebook,iphone,objective-c,xcode,facebook,uiimage,Iphone,Objective C,Xcode,Facebook,Uiimage,我正在努力寻找一些在facebook上发布的示例代码。下面是我找到的代码。但是,我可以知道如何修改它,以便我张贴图像而不是文本吗 FBStreamDialog* dialog = [[[FBStreamDialog alloc] init] autorelease]; dialog.userMessagePrompt = @"Enter your message:"; dialog.attachment = [NSString stringWithFormat:@"{\"name\":\"%@

我正在努力寻找一些在facebook上发布的示例代码。下面是我找到的代码。但是,我可以知道如何修改它,以便我张贴图像而不是文本吗

FBStreamDialog* dialog = [[[FBStreamDialog alloc] init] autorelease];
dialog.userMessagePrompt = @"Enter your message:";
dialog.attachment = [NSString stringWithFormat:@"{\"name\":\"%@ got straight A's!\",\"href\":\"http://www.raywenderlich.com/\",\"caption\":\"%@ must have gotten real lucky this time!\",\"description\":\"\",\"media\":[{\"type\":\"image\",\"src\":\"http://www.raywenderlich.com/wp-content/themes/raywenderlich/images/logo.png\",\"href\":\"http://www.raywenderlich.com/\"}]}", _facebookName, _facebookName];
dialog.actionLinks = @"[{\"text\":\"Get MyGrades!\",\"href\":\"http://www.raywenderlich.com/\"}]";
[dialog show];
另外,我试图张贴的图像是一个重叠的图像。这意味着它上面没有文件名。它是一个名为imageall的属性,如下代码所示

CGRect subviewFrame3 = [self.comment.superview convertRect:self.comment.frame toView:self.imageall]; [self.imageall addSubview:self.comment]; self.comment.frame = subviewFrame3;

UIGraphicsBeginImageContext(self.imageall.frame.size);
[self.imageall.layer renderInContext:UIGraphicsGetCurrentContext()];
UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsGetCurrentContext();

self.outputView.image = image;
非常感谢。

给你

- (void)uploadPhoto:(id)target {

//Just for demonstration.
    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];
    NSDictionary *params = nil;
    [[FBRequest requestWithDelegate:self] call:@"facebook.photos.upload" params:params dataParam:(NSData*)img];

}

有一个很好的框架叫做“AddThis”,用于共享图片、Facebook、twitter等(100多个社交网站)的链接

查看详细信息

您可以登录/注册此网站并转到

本指南将帮助您快速启动并运行iOS SDK。查看完整文档了解所有详细信息

检查嵌入下载的zip文件的演示应用程序

我向您保证,这是一个很好的使用框架


我已经成功地实现了它。如果你有任何疑问,请问我。愉快的编码。

嗨,Rahul,我尝试了你的方法,但按下按钮时没有弹出任何内容。Thanks@Clarence你需要读fbGraphAPI。你可以在谷歌上找到这个。让我为你做这件事。使用此链接,虽然它没有告诉你如何上传照片,但你会得到的想法实现FBGraphAPI的代码是从官方演示应用程序。。。也许可以看看整个项目