2012-10-06 3 views
2

: -포스트 IOS SDK 나는 다음과 같이 사용자의 벽에 이미지를 게시 할 수 있어요 3.0

if (appDelegate.session.isOpen) 
    { 
     FBSession.activeSession = appDelegate.session;    
     [FBRequestConnection startForUploadPhoto:img 
           completionHandler:^(FBRequestConnection *connection, id result, NSError *error) { 
            [self showAlert:@"eCard Posted" result:result error:error]; 
           }]; 

    } 

이제 요구 사항은 선택의 이미지를 친구 선택기 클래스에서 친구를 선택하고 게시하는 것입니다 친구 벽/타임 라인. 다음과 같이

나는 친구 선택기 클래스를 통합 한 -

위임 방법에 이제
if (appDelegate.session.isOpen) 
    { 
     FBSession.activeSession = appDelegate.session; 
     if (self.friendPickerController == nil) { 
      // Create friend picker, and get data loaded into it. 
      self.friendPickerController = [[FBFriendPickerViewController alloc] init]; 
      self.friendPickerController.title = @"Pick Friends"; 
      self.friendPickerController.delegate = self; 
     } 

     [self.friendPickerController loadData]; 
     [self.friendPickerController clearSelection];    
     [self presentModalViewController:self.friendPickerController animated:YES]; 


    } 

가 : -

- (void)facebookViewControllerDoneWasPressed:(id)sender { 

// we pick up the users from the selection, and create a string that we use to update the text view 
// at the bottom of the display; note that self.selection is a property inherited from our base class 
//UIImage *img = self.image; 
    FBSession.activeSession = appDelegate.session; 

for (id<FBGraphUser> user in self.friendPickerController.selection) { 

    FBSession.activeSession = appDelegate.session; 
    if (appDelegate.session.isOpen) 
    {    
     NSMutableDictionary *postVariablesDictionary = [[NSMutableDictionary alloc] init]; 
     // [postVariablesDictionary setObject:@"me" forKey:@"name"]; 
     // [postVariablesDictionary setObject:self.image forKey:@"picture"]; 
     [postVariablesDictionary setObject:@"Sample Text" forKey:@"message"]; 
     NSLog(@"%@",user.id); 
     [FBRequestConnection startForPostWithGraphPath:[NSString stringWithFormat:@"%@/feed",user.id] graphObject:[NSDictionary dictionaryWithDictionary:postVariablesDictionary] completionHandler:nil]; 


    }  
    else 
    { 
     if (appDelegate.session.state != FBSessionStateCreated) { 
      // Create a new, logged out session. 
      appDelegate.session = [[FBSession alloc] init]; 
     }    
     // if the session isn't open, let's open it now and present the login UX to the user 
     [appDelegate.session openWithCompletionHandler:^(FBSession *session, 
                 FBSessionState status, 
                 NSError *error) { 
     }]; 
    } 

} 

[self dismissModalViewControllerAnimated:YES]; 

}

위의 위임 방법은 항상로 연결됩니다 오류 코드 = 5 facebook SDK 오류입니다. 위 이미지를 선택한 친구 벽에 게시하려면 API를 호출해야합니다.

도와주세요 .......

답변

1

마지막으로 친구의 벽에 이미지를 게시 할 수 있습니다. 위의 코드

+0

근무

- (void)facebookViewControllerDoneWasPressed:(id)sender { // we pick up the users from the selection, and create a string that we use to update the text view // at the bottom of the display; note that self.selection is a property inherited from our base class //UIImage *img = self.image; FBSession.activeSession = appDelegate.session; if (appDelegate.session.isOpen) { [FBSession openActiveSessionWithPermissions:[NSArray arrayWithObjects:@"publish_stream",@"user_photos",@"", nil] allowLoginUI:NO completionHandler:^(FBSession *session, FBSessionState status, NSError *error) { if (error) { NSLog(@"error"); } else { [FBSession setActiveSession:appDelegate.session]; } }]; for (id<FBGraphUser> user in self.friendPickerController.selection) { if (appDelegate.session.isOpen) { FBSession.activeSession = appDelegate.session; NSMutableDictionary *postVariablesDictionary = [[NSMutableDictionary alloc] init]; [postVariablesDictionary setObject:self.image forKey:@"source"]; // [postVariablesDictionary setObject:UIImagePNGRepresentation(self.image) forKey:@"source"]; [postVariablesDictionary setObject:@"my image" forKey:@"message"]; NSLog(@"%@",user.id); [FBRequestConnection startWithGraphPath:[NSString stringWithFormat:@"%@/photos",user.id] parameters:postVariablesDictionary HTTPMethod:@"POST" completionHandler:^(FBRequestConnection *connection, id result, NSError *error) { [self showAlert:@"eCard Posted" result:result error:error]; }]; } else { if (appDelegate.session.state != FBSessionStateCreated) { // Create a new, logged out session. appDelegate.session = [[FBSession alloc] init]; } // if the session isn't open, let's open it now and present the login UX to the user [appDelegate.session openWithCompletionHandler:^(FBSession *session, FBSessionState status, NSError *error) { }]; } } } [self dismissModalViewControllerAnimated:YES]; 

}

시선 감사 .... - 다음과 같이

위임 방법 수정? – user23790

+0

예. 페이스 북 IOS SDK 3.0. – Sanjay

관련 문제