0

내 iPhone 앱 화면에서 Facebook 공유 옵션을 제공하고 있으며 사용자의 Facebook 프로필에서 일부 이미지와 URL을 공유해야합니다. ShareKit과 iOS 용 facebook sdk와 같은 여러 기능과 같은 여러 가지 타사 프레임 워크가 있음을 알고 있습니다. 그러나 이것은 내가 할 수있는 최선의 방법이며 지금까지 이미지 수에 표시된 공유 수와 함께 공유 버튼을 가져와야합니다.페이스 북의 iPhone 앱에서 내 페이지의 컨텐츠를 공유하려면 어떻게해야합니까?

enter image description here

아래 인증 리디렉션해야 클릭합니다. 그리고 iOS5 이상과 호환되어야합니다, 내 질문에 분명히 희망 바랍니다. 이 iOS6으로는 iOS6 있다면 미리

답변

0

에서

덕분에 연구

내 응용 프로그램 iOS4의 지원을 필요로 이후 페이스 북 Graph API 사용을 통해 질문을 자신을 해결 + 간단했을 것이다 페이스 북 통합과 필요를 가지고 있습니다 코드를 구현하기위한 몇 줄의 코드. 가 Graph APi 파일을 가져온 다음 코드를 추가 :

@synthesize facebook; 

//login with facebook 
- (IBAction) facebookButtonPressed { 
    if (!facebook || ![facebook isSessionValid]) { 
     self.facebook = [[[Facebook alloc] init] autorelease]; 
     NSArray *perms = [NSArray arrayWithObjects: @"read_stream", @"create_note", nil]; 
     [facebook authorize:FACEBOOK_API_KEY permissions:perms delegate:self]; 
    } 
    else { 
     [self fbDidLogin]; 
    } 
} 

//upload image once you're logged in 
-(void) fbDidLogin { 
    [self fbUploadImage]; 
} 

- (void) fbUploadImage 
{ 
    NSMutableDictionary * params = [NSMutableDictionary dictionaryWithObjectsAndKeys: 
            resultImage, @"picture", 
            nil]; 
    [facebook requestWithMethodName: @"photos.upload" 
          andParams: params 
         andHttpMethod: @"POST" 
         andDelegate: self]; 

    self.currentAlertView = [[[UIAlertView alloc] 
          initWithTitle:NSLocalizedString(@"Facebook", @"") 
          message:NSLocalizedString(@"Uploading to Facebook.", @"") 
          delegate:self 
          cancelButtonTitle:nil 
          otherButtonTitles: nil] autorelease]; 

    [self.currentAlertView show]; 
} 

//facebook error 
- (void)request:(FBRequest*)request didFailWithError:(NSError*)error 
{ 

    [self.currentAlertView dismissWithClickedButtonIndex:0 animated:YES]; 
    self.currentAlertView = nil; 

    UIAlertView *myAlert = [[UIAlertView alloc] 
          initWithTitle:NSLocalizedString(@"Error", @"") 
          message:NSLocalizedString(@"Facebook error message", @"") 
          delegate:self 
          cancelButtonTitle:nil 
          otherButtonTitles:@"OK", nil]; 
    [myAlert show]; 
    [myAlert release]; 
} 

//facebook success 
- (void)request:(FBRequest*)request didLoad:(id)result 
{ 
    [self.currentAlertView dismissWithClickedButtonIndex:0 animated:YES]; 
    self.currentAlertView = nil; 

    UIAlertView *myAlert = [[UIAlertView alloc] 
          initWithTitle:NSLocalizedString(@"Facebook", @"") 
          message:NSLocalizedString(@"Uploaded to Facebook message", @"") 
          delegate:self 
          cancelButtonTitle:nil 
          otherButtonTitles:@"OK", nil]; 
    [myAlert show]; 
    [myAlert release]; 
} 

와 페이스 북에서 특정 URL의 주 수를 얻기 위해, 사용

http://graph.facebook.com/?id=url 

을하지만이 모든 좋아하는, 주식의 수를 반환 게시물을 모두 게시해야하므로 더 나은 대안을 찾아야합니다.

희망이 도움이되었습니다. 감사합니다.

관련 문제