How to take a screenshot in your App and publish it on facebook?

Discussion in 'iPhone/iPad Programming' started by BarryK88, Jun 6, 2011.

  1. macrumors member

    Joined:
    Mar 1, 2011
    #1
    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:

    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:

    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!
     
  2. macrumors 6502

    dantastic

    Joined:
    Jan 21, 2011
    #2
    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.
     

Share This Page