如何在您的应用程序中截取屏幕截图并将其发布到 Facebook 上?
我试图通过在墙上发布我的应用程序的屏幕截图来在我的应用程序中使用 facebook。
的功能
UIGraphicsBeginImageContext(self.view.bounds.size);
[self.view.layer renderInContext:UIGraphicsGetCurrentContext()];
UIImage *viewImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
UIImageWriteToSavedPhotosAlbum(viewImage, nil, nil, nil);
我已经制作了用于截取屏幕截图和在我的 Facebook 墙上发布带有图标、标题和小描述的内容
- (void)postToWall {
FBStreamDialog* dialog = [[[FBStreamDialog alloc] init] autorelease];
dialog.userMessagePrompt = @"Enter your message:";
dialog.attachment = [NSString stringWithFormat:@"{\"name\":\"%@ share's a photo\",\"href\":\"mywebsite.com/\",\"caption\":\"%@thinks this is a nice photo\",\"description\":\"\",\"media\":[{\"type\":\"image\",\"src\":\"mywebsite.com/icon.png\",\"href\":\"mywebsite.com/\"}]}",
_facebookName, _facebookName];
dialog.actionLinks = @"[{\"text\":\"Get My App\",\"href\":\"http://itunes.apple.com//\"}]";
}
。关于如何将我的屏幕截图放入 postToWall 方法中,有什么建议吗?提前致谢!
I'm trying to use facebook within my App by posting a screenshot of my App on my wall.
I already made the functions for taking a screenshot
UIGraphicsBeginImageContext(self.view.bounds.size);
[self.view.layer renderInContext:UIGraphicsGetCurrentContext()];
UIImage *viewImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
UIImageWriteToSavedPhotosAlbum(viewImage, nil, nil, nil);
and for posting stuff on my facebook wall with an icon, title and small description.
- (void)postToWall {
FBStreamDialog* dialog = [[[FBStreamDialog alloc] init] autorelease];
dialog.userMessagePrompt = @"Enter your message:";
dialog.attachment = [NSString stringWithFormat:@"{\"name\":\"%@ share's a photo\",\"href\":\"mywebsite.com/\",\"caption\":\"%@thinks this is a nice photo\",\"description\":\"\",\"media\":[{\"type\":\"image\",\"src\":\"mywebsite.com/icon.png\",\"href\":\"mywebsite.com/\"}]}",
_facebookName, _facebookName];
dialog.actionLinks = @"[{\"text\":\"Get My App\",\"href\":\"http://itunes.apple.com//\"}]";
}
Any suggestions of how to put my screenshot within the postToWall method? Thanks in advance!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
使用 Facebook 的 iPhone SDK,这是可能的。您需要构建参数块 (NSDictionary) 并将其发送到经过验证的 Facebook 会话。
在此处的代码片段中,“会话”是 SDK 的 Facebook.h 中定义的 Facebook * 类型。
Using Facebook's SDK for iPhone, it is possible. You will need to construct and argument block (NSDictionary) and send that to the your validated Facebook session.
In the snippet here, "session" is of type Facebook * defined in Facebook.h of the SDK.
看来你不能完全通过 Facebook 来做到这一点。您应该查看照片共享网站。首先将您的图像上传到该网站并获取链接。然后通过这个方法分享出来。
编辑
我并不是说照片上传是不可能的。如果不先上传照片,就无法将照片连同应用程序的链接发布到墙上。
It seems like you can't do this completely via Facebook. You should look at photo sharing sites for this. First upload your image to that site and get the link. Then share it via this method.
Edit
I am not saying the photo upload isn't possible. It just isn't possible to post a photo to the wall along with a link to your app without uploading it first.