PDA

View Full Version : How to take a screenshot in your App and publish it on facebook?




BarryK88
Jun 6, 2011, 09:22 AM
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

Code:

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.

Code:

- (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!



dantastic
Jun 6, 2011, 11:18 AM
Will you please stop posting the same questions in multiple forums.

Is that not part of the facebook demo app btw? could have sworn I saw "post a photo" when I was looking at that.