Search code examples
iphonefbconnect

FBConnect - uploading images to Wall


i've configured FBConnect and it uploads to the wall, but what i want to do is take a screenshot and then upload the screenshot to FB.

In the below code there is an image but as a url. Can i intersect this and put in my screenshot image?

 FBStreamDialog *dialog = [[[FBStreamDialog alloc] init]autorelease];
             dialog.userMessagePrompt = @"Tell your friends about Fridgit!!:";
             dialog.attachment = [NSString stringWithFormat:@"{\"name\":\"Facebook Connect for iPhone\",\"href\":\"http://developers.facebook.com/connect.phptab=iphone\",\"caption\":\"Caption\",\"description\":\"Description\",\"media\":[{\"type\":\"image\",\"src\":\"screenShot\",\"href\":\"http://developers.facebook.com/connect.php?tab=iphone/\"}],\"properties\":{\"another link\":{\"text\":\"Facebook home page\",\"href\":\"http://www.facebook.com\"}}}", self.screenShot];                
 [dialog show];

}

i know all the code is default i haven't edited it yet incase i can't do what i want to do.

Cheers


Solution

  • Yes its possible with the new FB API nw, they made it as simple as possible

    // code snippet to take a snapshot
    // REF: http://stackoverflow.com/questions/2200736/how-to-take-a-screenshot-programmatically
    
    UIGraphicsBeginImageContext(self.window.bounds.size);
        [self.window.layer renderInContext:UIGraphicsGetCurrentContext()];
        UIImage *img = UIGraphicsGetImageFromCurrentImageContext();
        UIGraphicsEndImageContext();
    
    NSMutableDictionary *params = [NSMutableDictionary dictionaryWithObjectsAndKeys:
                                       img, @"picture",
                                       nil];
    
        [_facebook requestWithGraphPath:@"me/photos"
                              andParams:params
                          andHttpMethod:@"POST"
                            andDelegate:self];