私のiPhoneアプリでは、Facebook情報にアクセスしてサーバーに送信しています。サーバー Facebook 共有から、FB でアプリを作成しました。同期ボタンをクリックすると、FB ログイン ページに移動できます。ログイン後、認証を求められます。
しかし、公開共有などではなく、「基本情報」を要求するだけです(FBアプリに含めました)
-(IBAction)fbConnect:(id)sender{
flag = 1;
AppDelegate *appDelegate = [[UIApplication sharedApplication]delegate];
if (appDelegate.session.isOpen) {
[self updateView];
} else {
if (appDelegate.session.state != FBSessionStateCreated) {
appDelegate.session = [[FBSession alloc] init];
}
[appDelegate.session openWithCompletionHandler:^(FBSession *session,
FBSessionState status,
NSError *error) {
[self updateView];
}];
}
NSLog(@"string issss %@",string);
}
- (void)updateView {
AppDelegate *appDelegate = [[UIApplication sharedApplication]delegate];
if (appDelegate.session.isOpen) {
string = [NSString stringWithFormat:@"%@",
appDelegate.session.accessToken];
NSLog(@"string issss %@",string);
NSString *urlstrng;
if(flag == 1){
urlstrng = [NSString stringWithFormat:@"https://graph.facebook.com/me?access_token=%@",string];
[self dataFetching:urlstrng];
}
if(flag == 2){
urlstrng = [NSString stringWithFormat:@"https://graph.facebook.com/me/friends? access_token=%@",string];
[self dataFetching:urlstrng];
}
} else {
string = [NSString stringWithFormat:@"%@",
appDelegate.session.accessToken];
NSString *urlstrng;
if(flag == 1){
urlstrng = [NSString stringWithFormat:@"https://graph.facebook.com/me?access_token=%@",string];
[self dataFetching:urlstrng];
}
if(flag == 2){
urlstrng = [NSString stringWithFormat:@"https://graph.facebook.com/me/friends?access_token=%@",string];
[self dataFetching:urlstrng];
}
}
}
-(void)dataFetching:(NSString*)strng1{
NSURL *url = [NSURL URLWithString:strng1];
ProfileConnector *obj = [[ProfileConnector alloc] init];
obj.delegate1 = self;
[obj parsingJson:url];
}