에서
덕분에 연구
내 응용 프로그램 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
을하지만이 모든 좋아하는, 주식의 수를 반환 게시물을 모두 게시해야하므로 더 나은 대안을 찾아야합니다.
희망이 도움이되었습니다. 감사합니다.