Friday, 31 January 2014

To post message with image on facebook wall

- (IBAction)postStatusUpdateClick:(UIButton *)sender {
    // Post a status update to the user's feed via the Graph API, and display an alert view
    // with the results or an error.
    UIImage *imag=[UIImage imageNamed:@"f connect.png"];
    NSMutableDictionary* params = [[NSMutableDictionary alloc] init];
    [params setObject:@"your custom message" forKey:@"message"];
    [params setObject:UIImagePNGRepresentation(imag) forKey:@"picture"];
   // _shareToFbBtn.enabled = NO; //for not allowing multiple hits
    [FBRequestConnection startWithGraphPath:@"me/photos"
                          completionHandler:^(FBRequestConnection *connection,
                                              id result,
                                              NSError *error)
         if (error)
             //showing an alert for failure
             //[self showAlert:@"Facebook" message:@"Unable to share the photo please try later."];
             NSString *msg=@"Unable to share the photo please try later.";
             [self showAlert:msg result:result error:error];
             //showing an alert for success
             //[UIUtils showAlert:@"Facebook" message:@"Shared the photo successfully"];
          NSString *msg=@"Shared the photo successfully";
              [self showAlert:msg result:result error:error];
        // _shareToFbBtn.enabled = YES;