2012-05-31 14 views
8
NSMutableDictionary *params = [NSMutableDictionary dictionaryWithObjectsAndKeys: 
           photoDescription, @"message", 
           image, @"image", 
           nil]; 


[facebook requestWithGraphPath:@"me/photos" 
            andParams:params 
           andHttpMethod:@"POST" 
            andDelegate:self]; 

Questo è quello che ho fatto per caricare un'immagine su Facebook. L'immagine viene caricata con successo su "foto" di FaceBook. Ma voglio postare l'immagine sul mio feed FaceBook. Così ho provato,iPhone postare immagini su Facebook Feed

[facebook requestWithGraphPath:@"me/feed" 
            andParams:params 
           andHttpMethod:@"POST" 
            andDelegate:self]; 

ma ancora le immagini inviate alla 'foto'. Non appare nel feed ...

Ho cercato e usato diversi metodi per una soluzione, ma non ho trovato nulla di utile ...

risposta

1

Non sei sicuro di ciò che il vostro params assomiglia, ma provate questo ..

UIImage *image = ...// some image. 

NSData *imageData= UIImagePNGRepresentation(image); 

NSMutableDictionary *params = [NSMutableDictionary dictionaryWithObjectsAndKeys: 
          @"some message", @"message", imageData,@"source", nil]; 

[facebook dialog:@"feed" andParams:params andDelegate:self]; 
+0

credo che questo è lo stesso come la soluzione nella questione. In altre parole, pubblicherà solo la cronologia degli utenti, non il feed delle notizie. –

+0

Ho modificato la mia risposta per utilizzare il metodo di dialogo di Facebook e non la richiesta del grafico. Non posso testare adesso, ma spero che sia la risposta – skram

+0

Ho appena provato la tua soluzione ma non ha pubblicato l'immagine su Facebook. Ho pensato che anche la finestra di dialogo 'feed' sarebbe stata corretta. Ho anche provato "me/feed" che non ha funzionato neanche. –

0
UIImage* image=...; 
if ([FBSession.activeSession.permissions 
     indexOfObject:@"publish_actions"] == NSNotFound) { 

     NSArray *permissions = 
     [NSArray arrayWithObjects:@"publish_actions",@"publish_stream", nil]; 
     [[FBSession activeSession] requestNewPublishPermissions:permissions defaultAudience:FBSessionDefaultAudienceFriends 
               completionHandler:^(FBSession *session, NSError *error) {}]; 
    } 
    else 
    { 
    NSMutableDictionary* params = [[NSMutableDictionary alloc] init]; 
    [params setObject:@"Photo post test..." forKey:@"message"]; 
    [params setObject:UIImagePNGRepresentation(image) forKey:@"picture"]; 
    //for not allowing multiple hits 

     [FBRequestConnection startWithGraphPath:@"me/photos" 
           parameters:params 
           HTTPMethod:@"POST" 
          completionHandler:^(FBRequestConnection *connection, 
               id result, 
               NSError *error) 
    { 
     if (error) 
     { 
      //showing an alert for failure 
      UIAlertView *alertView = [[UIAlertView alloc] 
             initWithTitle:@"Post Failed" 
             message:error.localizedDescription 
             delegate:nil 
             cancelButtonTitle:@"OK" 
             otherButtonTitles:nil]; 
      [alertView show]; 

     } 
     else 
     { 
      //showing an alert for success 
      UIAlertView *alertView = [[UIAlertView alloc] 
             initWithTitle:@"Post success" 
             message:@"Shared the photo successfully" 
             delegate:nil 
             cancelButtonTitle:@"OK" 
             otherButtonTitles:nil]; 
      [alertView show]; 

     } 
    }]; 
    } 
Problemi correlati