SlideShare une entreprise Scribd logo
1  sur  77
FaceBook OPEN API
  - Grahp Story-
  Develop S.O.Lab by 이상온
Face Book API 3 TPYE

WebSite 안에서 Face Book 연동 Api

모바일 단말기에서 Face Book 연동앱개발

facebook.com 내의 앱개발
http://developers.facebook.com




모바일 선택 = IOS/AndRoid
목차
1. Facebook SDK install
2. Run the sample
3. Create Facebook App
4. Start new X-code Project
5. FACEBOOK Login & Authenticate
6. Personalize
7. Show Friends
8. Show Nearby Places
9. Publish to Feed
Step 1:   Facebook SDK install




   Facebook SDK install
Step 1:   Facebook SDK install
Step 2:    Run the sample
Basic samples
 •   HelloFacebookSample: combines use of FBLoginView, FBProfilePictureView,
     FBFriendsPickerViewController, FBPlacePickerViewController, and FBRequest for
     profile access, status updates and photo uploading.
 •   ProfilePictureSample: demonstrates non-logged-in usage of the
     FBProfilePictureView control.
 •   FriendPickerSample: demonstrates usage of the native multi-friend selector control
     to choose amongst the logged-in users' friends.
 •   PlacePickerSample: demonstrates logged-in usage of the FBPlacePickerView
     control.
More in-depth single feature samples
 •   SessionLoginSample: demonstrates detailed login flow via FBSession.
 •   JustRequestSample: demonstrates logged in user making a request of Facebook via
     FBRequest and FBRequestConnection, including batched requests.
 •   BooleanOGSample: demonstrates publishing an Open Graph custom action type.
More complete and special-case samples
 •   Scrumptious: integrated sample app demonstrating the use of login, requests, Place
     Picker, Friend Picker, Picture Upload, and Open Graph Publishing.
 •   SwitchUserSample: demonstrates an approach to allow switching logins between
     multiple users - for example, on a shared family iPad.
Step 3:   Create Facebook App




앱ID/API Key
앱 시크릿코드
Step 4:   Start new X-code Project
Step 4:   Start new X-code Project
Step 4:   Start new X-code Project

Add the Facebook SDK for iOS Framework by dragging the FacebookSDK.frameworkfolder
from the SDK installation folder into the Frameworks section of your Project Navigator.
Step 4:   Start new X-code Project

Add the Facebook SDK for iOS resource bundle by dragging
theFacebookSDKResources.bundle file from theFacebookSDK.framework/
Resources folder into the Frameworks section of your Project Navigator.
Step 4:   Start new X-code Project
Add the ''-lsqlite3.0'' SQL library to the list of build dependencies
Step 4:     Start new X-code Project
Finally, you need to place the Facebook app ID in two places in your application's
main.plist file. Create a key called FacebookAppID with a string value, and add
the app ID there:




                                   250959118344050
Step 4:     Start new X-code Project

    Also, create an array key called URL types with a single array sub-item called URL
    Schemes. Give this a single item with your app ID prefixed with fb:




This is used to ensure the application will receive the callback URL of the web-based OAuth flow.
Step 5:   FACEBOOK Login & Authenticate

FBsession 객체 : login & Authorize manage
• sessionOpenWithPermissions:completionHandler:
 함수를 호출하여 퍼미션를 선언하고 세션인증을 받을 콜백 핸들러를 제공
 한다.
• Facebook App으로부터 받을 핸들러 구성
• login or error 에대한 콜백핸들러 구현


MyAppViewController : 로그인 후
FBLoginViewController : 로그인 전
Step 5:   FACEBOOK Login & Authenticate

 New File > Object-c class > FBLoginViewController




xib 파일에서 Button & Activity Indicator 추가
Step 5:   FACEBOOK Login & Authenticate
한번 로그인 성공하고 나면 MYAppViewController 를 보여줄 것이다.
앱이 실행되면 먼저 저장되어있는 session를 체크하여 로그인/로그아웃 화면을 선택
한다.

실질적인 메인화면은 MyAppviewController 가 될것이며
FBLoginViewConroller는 필요할때만 모달로 나타날 것이다.



1. AppDelegate.m 파일에 해더 추가

      #import <FacebookSDK/FacebookSDK.h>


2. AppDelegate.m 파일에 FBLoginViewController 파일추가

      #import “FBLoginViewController“
Step 5:   FACEBOOK Login & Authenticate

3.로그인뷰가 모달로 보여질것임으로,,
  MyAppViewController needs to be part of a UINavigationController.
  AppDelegate.h 파일에 new navigation controller 선언

     @interface MyAppDelegate ()

     @property (strong, nonatomic)
     UINavigationController* navController;

     @end



4. AppDelegate.m 파일에 Synthesize this new property

      @synthesize navController = _navController;
Step 5:   FACEBOOK Login & Authenticate

5. AppDelegate.h 파일에 생성시 기본으로 만들어진
@property (strong, nonatomic) MyAppViewController *viewController;   를
@property (strong, nonatomic) MyAppViewController *mainViewController;
로 고친다




6. AppDelegate.m 파일에
  modify the synthesized property to have the new name by changing:


            @synthesize mainViewController = _mainViewController;
Step 5:    FACEBOOK Login & Authenticate


7. application:didFinishLaunchingWithOptions: method, change this code:

  self.mainViewController = [[MyAppViewController alloc]
                      initWithNibName:@"MyAppViewController_iPhone" bundle:nil];
  self.navController = [[UINavigationController alloc]
                   initWithRootViewController:self.mainViewController];
  self.window.rootViewController = self.navController;



8. AppDelegate.m 파일에 로그인뷰 보여줄 함수 구현

    - (void)showLoginView
    {
       UIViewController *topViewController = [self.navController topViewController];

        FBLoginViewController* loginViewController =
        [[FBLoginViewController alloc]initWithNibName:@"FBLoginViewController" bundle:nil];
        [topViewController presentModalViewController:loginViewController animated:NO];
    }
Step 5:      FACEBOOK Login & Authenticate


9. application:didFinishLaunchingWithOptions: method, change this code:
   FBSession을 채크하여 로그인화면 보여줄것인지 판단한는 함수 추가
         // See if we have a valid token for the current state.
         if (FBSession.activeSession.state == FBSessionStateCreatedTokenLoaded) {
             // To-do, show logged in view
         } else {
             // No, display the login page.
             [self showLoginView];
         }

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
   self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
   self.mainViewController = [[MyAppViewController alloc] initWithNibName:@"MyAppViewController_iPhone" bundle:nil];
   self.navController = [[UINavigationController alloc] initWithRootViewController:self.mainViewController];
   self.window.rootViewController = self.navController;

    [self.window makeKeyAndVisible];

    if (FBSession.activeSession.state == FBSessionStateCreatedTokenLoaded) {
        // To-do, show logged in view
    } else {
        // No, display the login page.
        [self showLoginView];
    }
    return YES;
}
Step 5:   FACEBOOK Login & Authenticate


10. FBLoginViewController.xib attach an action to the
    login button & outlet to the activity indicator IN FBLoginViewController.m
Step 5:   FACEBOOK Login & Authenticate
Step 5:   FACEBOOK Login & Authenticate


11. AppDelegate.m 파일에서 openSession 이라는 공용 메소드를 등록하고
    login버튼을 클릭시 이함수를 호출한다.




- (void)openSession
{
   [FBSession openActiveSessionWithPermissions:nil allowLoginUI:YES
completionHandler:
    ^(FBSession *session, FBSessionState state, NSError *error) {
        [self sessionStateChanged:session state:state error:error];
    }];
}
Step 5:    FACEBOOK Login & Authenticate

12. AppDelegate.m 파일에서 sessionStateChanged: state: error:이라는 메소드를
등록
 - (void)sessionStateChanged:(FBSession *)session state:(FBSessionState) state error:(NSError *)error
 {
    switch (state) {
        case FBSessionStateOpen: {
           UIViewController *topViewController =[self.navController topViewController];
           if ([[topViewController modalViewController] isKindOfClass:[FBLoginViewController class]]) {
               [topViewController dismissModalViewControllerAnimated:YES];
           }
        }
           break;
        case FBSessionStateClosed:
        case FBSessionStateClosedLoginFailed:
           [self.navController popToRootViewControllerAnimated:NO];
           [FBSession.activeSession closeAndClearTokenInformation];
           [self showLoginView];
           break;
        default:
           break;
    }
    if (error) {
        UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"Error"
                         message:error.localizedDescription
                         delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil];
        [alertView show];
    }
 }
Step 5:    FACEBOOK Login & Authenticate


13. application:didFinishLaunchingWithOptions: method, change this code:

    // See if we have a valid token for the current state.
    if (FBSession.activeSession.state == FBSessionStateCreatedTokenLoaded) {
        // To-do, show logged in view
           [self openSession];
    } else {
        // No, display the login page.
        [self showLoginView];
    }


14. App Delegate .h 파일에 함수 선언 추가

    - (void)openSession;
Step 5:   FACEBOOK Login & Authenticate


15. FBLoginViewController.m 파일에 import

     #import "MyAppDelegate.h"




16. FBLoginViewController.m - (IBAction)performLogin:(id)sender 함수 구
현
 - (IBAction)performLogin:(id)sender
 {
     [self.spinner startAnimating];

     SCAppDelegate* appDelegate = [UIApplication sharedApplication].delegate;
     [appDelegate openSession];
 }
Step 5:     FACEBOOK Login & Authenticate


17. FBLoginViewController.m - (void)loginFailed; 함수 구현

     - (void)loginFailed
     {
        // User switched back to the app without authorizing. Stay here, but
        // stop the spinner.
        [self.spinner stopAnimating];
     }



18. FBLoginViewController.h - (void)loginFailed; 함수 선언

     - (void)loginFailed;
Step 5:    FACEBOOK Login & Authenticate


    19. AppDelegate.m 파일의 showLoginView 함수를 수정

- (void)showLoginView
{
    NSLog(@"showLoginView ~~함수 호출");
   UIViewController *topViewController = [self.navController topViewController];
   /*
   FBLoginViewController* loginViewController = [[FBLoginViewController alloc]
initWithNibName:@"FBLoginViewController" bundle:nil];
   [topViewController presentModalViewController:loginViewController animated:NO];
   */
   UIViewController *modalViewController = [topViewController modalViewController];

    if (![modalViewController isKindOfClass:[FBLoginViewController class]]) {
        FBLoginViewController* loginViewController = [[FBLoginViewController alloc]
                                      initWithNibName:@"FBLoginViewController"
                                      bundle:nil];
        [topViewController presentModalViewController:loginViewController animated:NO];
    } else {
        FBLoginViewController* loginViewController =
        (FBLoginViewController*)modalViewController;
        [loginViewController loginFailed];
    }
}
Step 5:    FACEBOOK Login & Authenticate

20. Facebook 에 로그인하는동안 App 이나 safari를 통해 컨트롤을 보내고 인증
받은
   후에 session 정보를 받아온다.
  이것을 수행하는 (BOOL)application:(UIApplication *)application openURL
  함수를 AppDelegate.m 파일에 구현

  - (BOOL)application:(UIApplication *)application openURL:(NSURL *)url
    sourceApplication:(NSString *)sourceApplication
        annotation:(id)annotation
  {
     return [FBSession.activeSession handleOpenURL:url];
  }



21. Facebook 인증중에 사용자가 폰을종료시켜버릴경우 세션도 종료시켜야 함
으로
    applicationDidBecomeActive: delegate 메소드에 다음을 추가한다.
  if (FBSession.activeSession.state == FBSessionStateCreatedOpening) {
      [FBSession.activeSession close]; // so we close our session and start over
  }
Step 5:    FACEBOOK Login & Authenticate


22. MyAppViewController.m 파일에 해더를 추가

     #import <FacebookSDK/FacebookSDK.h>




23. MyAppViewController.m 파일의 viewDidLoad 함수에 추가

    self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc]
                                 initWithTitle:@"Logout"
                                 style:UIBarButtonItemStyleBordered
                                 target:self
                                 action:@selector(logoutButtonWasPressed:)];


24. MyAppViewController.m 파일의 logoutButtonWasPressed 함수에 추가

    -(void)logoutButtonWasPressed:(id)sender {
       [FBSession.activeSession closeAndClearTokenInformation];
    }
Step 6:   Personalize

        displaying the user's profile picture and name when they've authenticated.

1) Facebook SDK FBRequest object
2) activeSession on FBSession has been opened, or else provide an explicit FBSession
   instance to the FBRequestcalls.
3) requestForMeWithSession that returns an FBRequestobject
4) The user data will be a strongly typed FBGraphUser object
5) Once you've constructed an FBRequest object, you can initiate the API call by invoking
   thestartWithCompletionHandler: method.




                          View 추가후 class 를 FBProfilePictureView로 셋팅




                          XIB 객체선택후 ctl + 드레그 to 소스코드
Step 6:   Personalize
Step 6:    Personalize

            User info Display function구현


  - (void)populateUserDetails
  {
     if (FBSession.activeSession.isOpen) {
         [[FBRequest requestForMe] startWithCompletionHandler:
          ^(FBRequestConnection *connection,
            NSDictionary<FBGraphUser> *user,
            NSError *error) {
              if (!error) {
                  self.userNameLabel.text = user.name;
                  self.userProfileImage.profileID = user.id;
              }
          }];
     }
  }


              이함수가 성공적으로 실행되면
FBProfilePictureView 객체의 Property에 정보를 셋팅한다.
Step 6:   Personalize

 로그인 상태에서 정보를 바로 보여주기위한 function구현



        -(void)viewWillAppear:(BOOL)animated{
           [super viewWillAppear:animated];

            if (FBSession.activeSession.isOpen) {
                [self populateUserDetails];
            }
        }




페이지 로딩시 이함수가 실행되면서 사용자정보를 바로 보여준다.
Step 6:   Personalize

업데이트된 사용자 정보를 어느때나 보고 싶다면 Active Session이 바뀔때마다
       NSNotificationCenter를 notified하여 제공할수 있다.



  1.AppDelegate.h 파일에 다음을 선언한다.

   extern NSString *const SCSessionStateChangedNotification;



  2.AppDelegate.m 파일에 다음을 추가한다.


    NSString *const SCSessionStateChangedNotification =
      @"com.solab.FaceBookApiFirst:FBSessionStateChangedNotification";
Step 6:       Personalize
1.AppDelegate.m 파일의 -(void)sessionStateChanged:(FBSession *)session
함수안에 notification을 추가하여 세션변경때마다 호출한다.

- (void)sessionStateChanged:(FBSession *)session
                      state:(FBSessionState) state
                      error:(NSError *)error
{
    switch (state) {
        case FBSessionStateOpen: {
            UIViewController *topViewController =
            [self.navController topViewController];
            if ([[topViewController modalViewController]
                 isKindOfClass:[FBLoginViewController class]]) {
                [topViewController dismissModalViewControllerAnimated:YES];
            }
        }
            break;
        case FBSessionStateClosed:
        case FBSessionStateClosedLoginFailed:
            // Once the user has logged in, we want them to
            // be looking at the root view.
            [self.navController popToRootViewControllerAnimated:NO];

            [FBSession.activeSession closeAndClearTokenInformation];

            [self showLoginView];
            break;
        default:
            break;
    }

    [[NSNotificationCenter defaultCenter] postNotificationName:FBSessionStateChangedNotification
                                                         object:session];


    if (error) {
        UIAlertView *alertView = [[UIAlertView alloc]
                                  initWithTitle:@"Error"
                                  message:error.localizedDescription
                                  delegate:nil
                                  cancelButtonTitle:@"OK"
                                  otherButtonTitles:nil];
        [alertView show];
    }
}
Step 6:   Personalize

1.오류 수정

    2012-05-18 04:04:11.620 Scrumptious[6548:f803] Unknown class
    FBProfilePictureView in Interface Builder file.




add this as the first line in the app
delegate's
application:didFinishLaunchingWit
hOptions:method:


    [FBProfilePictureView class];
Step 7:   Show Friends

1.Facebook 친구들의 정보를 가져오기 위해서는 FBFriendPickerViewController
  객체를 이용하면 된다.
2.FBFriendPickerViewController 을 사용하기 위해서는 initWithNibName:bundle:
  함수 안에서 객체를 생성한다.
3.FBFriendPickerDelegate notifications 객체를 정의하기위한 델이게이트 메소드
  를 셋팅한다.
4.마지막으로 loadData 함수를 호출하면 FBFriendPickerViewController에 친구
  정보가 보여진다.


      FBFriendPickerDelegate
      friendPickerViewControllerSelectionDidChange:
      FBFriendPickerViewController
      selection property
Step 7:     Show Friends


1.Set Up the User Interface


     Add a Table View object

    Style: Grouped;
    Show Selection on Touch: NO;
    Scrolling Enabled: NO;

•   Create an outlet for the Table View object and call it
    menuTableView.
•   Connect the dataSource outlet to the File's Owner.
•   Connect the delegate outlet to the File's Owner.
Step 7:     Show Friends

1.Set Up The Menu Display


 MyAppViewController.m 파일에 선언

 @interface SCViewController ()
 <UITableViewDataSource,UITableViewDelegate>



 MyAppViewController.m 파일에 TableView delegate 구현

  - (UITableViewCell *)tableView:(UITableView *)tableView
      cellForRowAtIndexPath:(NSIndexPath *)indexPath
  {
     static NSString *CellIdentifier = @"Cell";

    UITableViewCell *cell = (UITableViewCell*)[tableView
        dequeueReusableCellWithIdentifier:CellIdentifier];
    if (cell == nil) {
        cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle
          reuseIdentifier:CellIdentifier];
        cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
        cell.selectionStyle = UITableViewCellSelectionStyleNone;
Step 7:    Show Friends
    cell.textLabel.font = [UIFont systemFontOfSize:16];
    cell.textLabel.backgroundColor = [UIColor colorWithWhite:0 alpha:0];
    cell.textLabel.lineBreakMode = UILineBreakModeTailTruncation;
    cell.textLabel.clipsToBounds = YES;

    cell.detailTextLabel.font = [UIFont systemFontOfSize:12];
    cell.detailTextLabel.backgroundColor = [UIColor colorWithWhite:0 alpha:0];
    cell.detailTextLabel.textColor = [UIColor colorWithRed:0.4
                                    green:0.6
                                     blue:0.8
                                    alpha:1];
    cell.detailTextLabel.lineBreakMode = UILineBreakModeTailTruncation;
    cell.detailTextLabel.clipsToBounds = YES;
}

switch (indexPath.row) {
  case 0:
     cell.textLabel.text = @"What are you eating?";
     cell.detailTextLabel.text = @"Select one";
     cell.imageView.image = [UIImage imageNamed:@"action-eating.png"];
     break;

    case 1:
      cell.textLabel.text = @"Where are you?";
      cell.detailTextLabel.text = @"Select one";
      cell.imageView.image = [UIImage imageNamed:@"action-location.png"];
      break;
Step 7:   Show Friends


case 2:
          cell.textLabel.text = @"With whom?";
          cell.detailTextLabel.text = @"Select friends";
          cell.imageView.image = [UIImage imageNamed:@"action-people.png"];
          break;

        case 3:
          cell.textLabel.text = @"Got a picture?";
          cell.detailTextLabel.text = @"Take one";
          cell.imageView.image = [UIImage imageNamed:@"action-photo.png"];
          break;

        default:
          break;
    }

    return cell;
}
Step 7:    Show Friends


- (NSInteger)tableView:(UITableView *)tableView
numberOfRowsInSection:(NSInteger)section
{
   return 4;
}

- (NSInteger)numberOfSectionsInTableView:(UITableView
*)tableView
{
   return 1;
}



- (void)tableView:(UITableView *)tableView
didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
   // Do nothing for now
}
Step 7:   Show Friends

1.Show the Friend Selector


   MyAppViewController.m 파일에 추가

   @property (strong, nonatomic) FBFriendPickerViewController
   *friendPickerController;
   @synthesize friendPickerController = _friendPickerController;



    ViewdidUnLoad 함수에 추가


    self.friendPickerController = nil;
Step 7:     Show Friends

        tableView:didSelectRowAtIndexPath: 델리게이트 함수를 수정


- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
   switch (indexPath.row) {
      case 2:
         if (!self.friendPickerController) {
             self.friendPickerController = [[FBFriendPickerViewController alloc]
                initWithNibName:nil bundle:nil];
             self.friendPickerController.title = @"Select friends";
         }

         [self.friendPickerController loadData];
         [self.navigationController pushViewController:self.friendPickerController
            animated:true];
    }
}
Step 7:   Show Friends
Step 7:   Show Friends

1.Display Selected Friends

     tableView:didSelectRowAtIndexPath: 함수에 다음 코드를 추가
     한다.

                self.friendPickerController.delegate = self;



     Add the dealloc method

     - (void)dealloc
     {
        _friendPickerController.delegate = nil;
     }
Step 7:   Show Friends

1.Display Selected Friends


    @property (strong, nonatomic) NSArray* selectedFriends;
    @synthesize selectedFriends = _selectedFriends;




   - (void)updateCellIndex:(int)index withSubtitle:(NSString*)subtitle {
      UITableViewCell *cell = (UITableViewCell *)[self.menuTableView
         cellForRowAtIndexPath:[NSIndexPath indexPathForRow:index
   inSection:0]];
      cell.detailTextLabel.text = subtitle;
   }
Step 7:    Show Friends

- (void)updateSelections
{

    NSString* friendsSubtitle = @"Select friends";
    int friendCount = self.selectedFriends.count;
    if (friendCount > 2) {
        // Just to mix things up, don't always show the first friend.
        id<FBGraphUser> randomFriend =
            [self.selectedFriends objectAtIndex:arc4random() % friendCount];
        friendsSubtitle = [NSString stringWithFormat:@"%@ and %d others",
            randomFriend.name,
            friendCount - 1];
    } else if (friendCount == 2) {
        id<FBGraphUser> friend1 = [self.selectedFriends objectAtIndex:0];
        id<FBGraphUser> friend2 = [self.selectedFriends objectAtIndex:1];
        friendsSubtitle = [NSString stringWithFormat:@"%@ and %@",
            friend1.name,
            friend2.name];
    } else if (friendCount == 1) {
        id<FBGraphUser> friend = [self.selectedFriends objectAtIndex:0];
        friendsSubtitle = friend.name;
    }
    [self updateCellIndex:2 withSubtitle:friendsSubtitle];
}
Step 7:   Show Friends


Implement the FBFriendPickerDelegate method that will be notified of a friend selection



         - (void)friendPickerViewControllerSelectionDidChange:
         (FBFriendPickerViewController *)friendPicker
         {
            self.selectedFriends = friendPicker.selection;
            [self updateSelections];
         }
Step 7:   Show Friends
Step 8:   Show Nearby Places

1.Facebook 친구들의 정보를 가져오기 위해서는 FBPlacePickerViewController
  객체를 이용하면 된다.
2.FBFriendPickerViewController 을 사용하기 위해서는 initWithNibName:bundle:
  함수 안에서 객체를 생성한다.
3.FBPlacePickerDelegate notifications 객체를 정의하기위한 델이게이트 메소드
  를 셋팅한다.
4.마지막으로 loadData 함수를 호출하면 FBFriendPickerViewController에 친구
  정보가 보여진다.



     FBPlacePickerDelegate
     placePickerViewControllerSelectionDidChange:
     FBPlacePickerViewController
     selection property
     FBGraphPlace
Step 8:   Show Nearby Places

1.Add the Core Location Framework
Step 8:   Show Nearby Places

1.Get the User's Current Location


 MyAppViewController.m 파일에 추가



@property (strong, nonatomic) CLLocationManager *locationManager;
@synthesize locationManager = _locationManager;


viewDidLoad 함수에 추가

self.locationManager = [[CLLocationManager alloc] init];
self.locationManager.delegate = self;
self.locationManager.desiredAccuracy =
kCLLocationAccuracyNearestTenMeters;
self.locationManager.distanceFilter = 50;
[self.locationManager startUpdatingLocation];
Step 8:     Show Nearby Places

1.Get the User's Current Location

     MyAppViewController.m 파일에 추가

 - (void)locationManager:(CLLocationManager *)manager
    didUpdateToLocation:(CLLocation *)newLocation
          fromLocation:(CLLocation *)oldLocation
 {
    if (!oldLocation ||
        (oldLocation.coordinate.latitude != newLocation.coordinate.latitude &&
         oldLocation.coordinate.longitude != newLocation.coordinate.longitude)) {

         // To-do, add code for triggering view controller update
         NSLog(@"Got location: %f, %f",
              newLocation.coordinate.latitude,
              newLocation.coordinate.longitude);
     }
 }

 - (void)locationManager:(CLLocationManager *)manager
 didFailWithError:(NSError *)error {
    NSLog(@"%@", error);
 }
Step 8:    Show Nearby Places

1.Show the Nearby Place Selector

  MyAppViewController.m 파일에 추가
  @property (strong, nonatomic) FBPlacePickerViewController *placePickerController;
  @synthesize placePickerController = _placePickerController;


  tableView:didDeselectRowAtIndexPath 함수에 다음을 추가
  case 1:
    if (!self.placePickerController) {
        self.placePickerController = [[FBPlacePickerViewController alloc]
                            initWithNibName:nil bundle:nil];
        self.placePickerController.title = @"Select a restaurant";
    }
    self.placePickerController.locationCoordinate =
    self.locationManager.location.coordinate;
    self.placePickerController.radiusInMeters = 1000;
    self.placePickerController.resultsLimit = 50;
    self.placePickerController.searchText = @"restaurant";

    [self.placePickerController loadData];
    [self.navigationController pushViewController:self.placePickerController
                            animated:true];
    break;
Step 8:   Show Nearby Places
Step 8:     Show Nearby Places

1.Display the Selected Place

   tableView:didSelectRowAtIndexPath 메소드 수정

   self.placePickerController.delegate = self;



  MyAppviewController.m 에 다음을 추가
  @property (strong, nonatomic) NSObject<FBGraphPlace>* selectedPlace;
  @synthesize selectedPlace = _selectedPlace;




  updateSelections 함수에 다음을 추가

  [self updateCellIndex:1 withSubtitle:(self.selectedPlace ?
                                       self.selectedPlace.name :
                                       @"Select One")];
Step 8:   Show Nearby Places


FBPlacePickerDelegate 메소드 구현


- (void)placePickerViewControllerSelectionDidChange:
(FBPlacePickerViewController *)placePicker
{
   self.selectedPlace = placePicker.selection;
   [self updateSelections];
   if (self.selectedPlace.count > 0) {
       [self.navigationController popViewControllerAnimated:true];
   }
}
Step 9 : Publish to Feed

1.Facebook Timeline 의 구현을 Graph API를 사용하지 않고 대안으로
  구현할수있는 Feed Dialog 방법을 설명한다.
2. FBRequestConnection 클래스를 이용한다.
3. startWithGraphPath:parameters:HTTPMethod:completionHandler:
  함수를 사용한다.
4. USER_ID/feed 파라미터를 통하여 전달한다.




              1: Set Up the Share View Trigger
Step 9 : Publish to Feed


     1: Set Up the Share View Trigger


MyAppViewController.m 파일의 ViewDidLoad함수의 내용과 sessionStateChanged 함수의 내용을 변경

 - (void)viewDidLoad
 {
    [super viewDidLoad];
     // Do any additional setup after loading the view, typically from a nib.
    _loginButton = [UIButton buttonWithType:UIButtonTypeRoundedRect];
    [_loginButton setTitle:@"Publish" forState:UIControlStateNormal];
    _loginButton.frame = CGRectMake(80, 350, 150, 50);
    [_loginButton addTarget:self action:@selector(gofacebookpublish) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:_loginButton];


 - (void)sessionStateChanged:(NSNotification*)notification {
    if (FBSession.activeSession.isOpen) {
        self.loginButton.hidden = NO;
        } else {
        self.loginButton.hidden = YES;
        }

     [self populateUserDetails];
 }
Step 9 : Publish to Feed


 2: Ask for Publish Permissions

AppDelegate.m 파일의 함수에서 퍼미션을 설정한다.


- (void)openSession
{
   NSArray *permissions = [[NSArray alloc] initWithObjects:
                     @"publish_actions", nil];
   [FBSession openActiveSessionWithPermissions:permissions allowLoginUI:YES completionHandler:
    ^(FBSession *session, FBSessionState state, NSError *error) {
        [self sessionStateChanged:session state:state error:error];
    }];
}
Step 9 : Publish to Feed


 3: Set Up the Share View

3-1. FBFeedViewcontroller 새로 생성
Step 9 : Publish to Feed


 3: Set Up the Share View

3-2. FBFeedViewController.xib 파일에서 .m 파일로 드러그앤 코딩으로 Tool bar 구현한다.
Step 9 : Publish to Feed


     3: Set Up the Share View

3-3. FBFeedViewController.xib 파일에서 .m 파일로 드러그앤 코딩으로 나머지 구현한다.

Message:

 •    Add a Text View object to the view below the toolbar. Stretch it out to take up most of the view's width.
 •    In the Connections Inspector, connect the delegate outlet to the File's Owner.
 •    Add an outlet to your view controller's implementation file so it's private. Name the outlet ''postMessageTextView''.


Image:

 •   Add an Image View object to the view below the ''Message'' text view, to the left of the main view.
 •   In the Attributes Inspector, set the View > Mode to Aspect Fit.
 •   In the Size Inspector, set the width to 80 and the height to 80.
 •   Add an outlet to your view controller's implementation file so it's private. Name the outlet ''postImageView''.
Name:

 •    In the Attributes Inspector, set the text color to a dark blue and the font to System Bold.
 •    Add an outlet to your view controller's implementation file so it's private. Name the outlet ''postNameLabel''.
Caption:

 •    Add a Label object to the view. Place it below the ''Name'' label.
 •    In the Attributes Inspector, set the text color to a dark gray and the make the font size smaller than the ''Name'' label. Set the Lines attribute to 0.
 •    Add an outlet to your view controller's implementation file so it's private. Name the outlet ''postCaptionLabel''.
Description:

 •    Add a Label object to the view. Place it below the ''Caption'' label.
 •    In the Attributes Inspector, set the font size to be smaller than the ''Name'' label font size. Set the Lines attribute to 0.
 •    Add an outlet to your view controller's implementation file so it's private. Name the outlet ''postDescriptionLabel''.
Step 9 : Publish to Feed

3: Set Up the Share View

  3-3. FBFeedViewController.xib 파일에서 .m 파일로 드러그앤 코딩으로 나머지 구현한다.
Step 9 : Publish to Feed

3: Set Up the Share View

  3-3. FBFeedViewController.m 코딩




text view에 미리 쓰여질 문자열 설정




text view에 미리 쓰여질 문자열 함수 구현
Step 9 : Publish to Feed

3: Set Up the Share View

  3-3. FBFeedViewController.m 코딩 UITextViewDelegate 메스드 구현
Step 9 : Publish to Feed

3: Set Up the Share View

  3-4. Configure the Display Data




   initWithNibName:bundle 메소드에 추가
Step 9 : Publish to Feed

3: Set Up the Share View

  3-4. Configure the Display Data


     ViewDidLoad 메소드에 추가
Step 9 : Publish to Feed

3: Set Up the Share View

  3-5. Load the Story Image




    ViewDidLoad




    ViewDidUnLoad
Step 9 : Publish to Feed

3: Set Up the Share View

  3-5. Load the Story Image


         NSURLConnection delegate methods
        - (void)connection:(NSURLConnection*)connection
           didReceiveData:(NSData*)data{
           [self.imageData appendData:data];
        }

        - (void)connectionDidFinishLoading:(NSURLConnection *)connection{
           // Load the image
           self.postImageView.image = [UIImage imageWithData:
                             [NSData dataWithData:self.imageData]];
           self.imageConnection = nil;
           self.imageData = nil;
        }

        - (void)connection:(NSURLConnection *)connection
          didFailWithError:(NSError *)error{
           self.imageConnection = nil;
           self.imageData = nil;
        }
Step 9 : Publish to Feed

3: Set Up the Share View
  3-6. Configure the Cancel Action


   - (IBAction)cancelButtonAction:(id)sender {
       [[self presentingViewController]
        dismissModalViewControllerAnimated:YES];
   }


  3-7. Present the Share View


  FBFeedViewController.m 파일에 Import & 클릭함수 구현




   -(void) gofacebookpublish
   {
      FBFeedViewController *viewController = [[FBFeedViewController alloc]
                              initWithNibName:@"FBFeedViewController"
                              bundle:nil];
      [self presentViewController:viewController animated:YES completion:nil];
   }
Step 9 : Publish to Feed

4: Publish the Story

   FBFeedViewController.m 파일에 Import & 클릭함수 구현




- (IBAction)shareButtonAction:(id)sender {
    if ([self.postMessageTextView isFirstResponder]) {
        [self.postMessageTextView resignFirstResponder];
    }
    if (![self.postMessageTextView.text isEqualToString:kPlaceholderPostMessage] &&
        ![self.postMessageTextView.text isEqualToString:@""]) {
        [self.postParams setObject:self.postMessageTextView.text forKey:@"message"];
    }
    [FBRequestConnection startWithGraphPath:@"me/feed" parameters:self.postParams HTTPMethod:@"POST"
                                 completionHandler:^(FBRequestConnection *connection,id result,NSError *error) {
        NSString *alertText;
        if (error) {
            alertText = [NSString stringWithFormat:@"error: domain = %@, code = %d",error.domain, error.code];
        } else {
            alertText = [NSString stringWithFormat:@"Posted action, id: %@",[result objectForKey:@"id"]];
        }
        [[[UIAlertView alloc] initWithTitle:@"Result" message:alertText delegate:self cancelButtonTitle:@"OK!"
                         otherButtonTitles:nil] show];
    }];
}
Step 9 : Publish to Feed

4: Publish the Story

FBFeedViewController.m 파일에 UIAlertView delegate 함수 구현

Contenu connexe

Tendances

Integrate jQuery PHP MySQL project to JOOMLA web site
Integrate jQuery PHP MySQL project to JOOMLA web siteIntegrate jQuery PHP MySQL project to JOOMLA web site
Integrate jQuery PHP MySQL project to JOOMLA web siteHock Leng PUAH
 
Adding User Management to Node.js
Adding User Management to Node.jsAdding User Management to Node.js
Adding User Management to Node.jsDev_Events
 
Android Workshop
Android WorkshopAndroid Workshop
Android WorkshopJunda Ong
 
Aspnet mvc tutorial_01_cs
Aspnet mvc tutorial_01_csAspnet mvc tutorial_01_cs
Aspnet mvc tutorial_01_csAlfa Gama Omega
 
Point and Click App Building Workshop
Point and Click App Building WorkshopPoint and Click App Building Workshop
Point and Click App Building WorkshopSalesforce Developers
 
02 asp.net session02
02 asp.net session0202 asp.net session02
02 asp.net session02Mani Chaubey
 
What's New on the Facebook Platform, July 2011
What's New on the Facebook Platform, July 2011What's New on the Facebook Platform, July 2011
What's New on the Facebook Platform, July 2011Iskandar Najmuddin
 
Creating Openbravo Workspace Widgets
Creating Openbravo Workspace WidgetsCreating Openbravo Workspace Widgets
Creating Openbravo Workspace WidgetsRob Goris
 
Make an html validator extension
Make an html validator extensionMake an html validator extension
Make an html validator extensionRebecca Peltz
 
Introduction to Facebook JavaScript & Python SDK
Introduction to Facebook JavaScript & Python SDKIntroduction to Facebook JavaScript & Python SDK
Introduction to Facebook JavaScript & Python SDKColin Su
 
Getting started-with-oracle-so a-9
Getting started-with-oracle-so a-9Getting started-with-oracle-so a-9
Getting started-with-oracle-so a-9Amit Sharma
 
Level up apps and websites with vue.js
Level up  apps and websites with vue.jsLevel up  apps and websites with vue.js
Level up apps and websites with vue.jsVioletta Villani
 
Cis 407 i lab 6 of 7
Cis 407 i lab 6 of 7Cis 407 i lab 6 of 7
Cis 407 i lab 6 of 7helpido9
 
DotNet Nuke Document To Create Child Portal
DotNet Nuke Document To Create Child PortalDotNet Nuke Document To Create Child Portal
DotNet Nuke Document To Create Child PortalSanjeev Chaudhary
 
Static Reference Analysis for GUI Objects in Android Software
Static Reference Analysis for GUI Objects in Android SoftwareStatic Reference Analysis for GUI Objects in Android Software
Static Reference Analysis for GUI Objects in Android SoftwareDacong (Tony) Yan
 

Tendances (19)

Integrate jQuery PHP MySQL project to JOOMLA web site
Integrate jQuery PHP MySQL project to JOOMLA web siteIntegrate jQuery PHP MySQL project to JOOMLA web site
Integrate jQuery PHP MySQL project to JOOMLA web site
 
Adding User Management to Node.js
Adding User Management to Node.jsAdding User Management to Node.js
Adding User Management to Node.js
 
Android Workshop
Android WorkshopAndroid Workshop
Android Workshop
 
Aspnet mvc tutorial_01_cs
Aspnet mvc tutorial_01_csAspnet mvc tutorial_01_cs
Aspnet mvc tutorial_01_cs
 
Point and Click App Building Workshop
Point and Click App Building WorkshopPoint and Click App Building Workshop
Point and Click App Building Workshop
 
02 asp.net session02
02 asp.net session0202 asp.net session02
02 asp.net session02
 
What's New on the Facebook Platform, July 2011
What's New on the Facebook Platform, July 2011What's New on the Facebook Platform, July 2011
What's New on the Facebook Platform, July 2011
 
Creating Openbravo Workspace Widgets
Creating Openbravo Workspace WidgetsCreating Openbravo Workspace Widgets
Creating Openbravo Workspace Widgets
 
Make an html validator extension
Make an html validator extensionMake an html validator extension
Make an html validator extension
 
Layout
LayoutLayout
Layout
 
Introduction to Facebook JavaScript & Python SDK
Introduction to Facebook JavaScript & Python SDKIntroduction to Facebook JavaScript & Python SDK
Introduction to Facebook JavaScript & Python SDK
 
Getting started-with-oracle-so a-9
Getting started-with-oracle-so a-9Getting started-with-oracle-so a-9
Getting started-with-oracle-so a-9
 
Level up apps and websites with vue.js
Level up  apps and websites with vue.jsLevel up  apps and websites with vue.js
Level up apps and websites with vue.js
 
Chapter 09
Chapter 09Chapter 09
Chapter 09
 
C Sharp Cornerarticle
C Sharp CornerarticleC Sharp Cornerarticle
C Sharp Cornerarticle
 
Cis 407 i lab 6 of 7
Cis 407 i lab 6 of 7Cis 407 i lab 6 of 7
Cis 407 i lab 6 of 7
 
DotNet Nuke Document To Create Child Portal
DotNet Nuke Document To Create Child PortalDotNet Nuke Document To Create Child Portal
DotNet Nuke Document To Create Child Portal
 
Static Reference Analysis for GUI Objects in Android Software
Static Reference Analysis for GUI Objects in Android SoftwareStatic Reference Analysis for GUI Objects in Android Software
Static Reference Analysis for GUI Objects in Android Software
 
Dojo1.0_Tutorials
Dojo1.0_TutorialsDojo1.0_Tutorials
Dojo1.0_Tutorials
 

En vedette

Freelance Workshop Lecture1
Freelance Workshop Lecture1Freelance Workshop Lecture1
Freelance Workshop Lecture1Kareem Elzftawy
 
Responses of phytoplankton to a changing climate
Responses of phytoplankton to a changing climateResponses of phytoplankton to a changing climate
Responses of phytoplankton to a changing climateLancaster University
 
Presentacion3
Presentacion3Presentacion3
Presentacion3yoarean
 
Club der Freunde
Club der FreundeClub der Freunde
Club der Freundefudder
 
Banque Palatine / Opinionway : Observatoire de la performance des PME/ETI / J...
Banque Palatine / Opinionway : Observatoire de la performance des PME/ETI / J...Banque Palatine / Opinionway : Observatoire de la performance des PME/ETI / J...
Banque Palatine / Opinionway : Observatoire de la performance des PME/ETI / J...contactOpinionWay
 
Banque Palatine - Observatoire de la performance des PME-ETI - Par OpinionWay...
Banque Palatine - Observatoire de la performance des PME-ETI - Par OpinionWay...Banque Palatine - Observatoire de la performance des PME-ETI - Par OpinionWay...
Banque Palatine - Observatoire de la performance des PME-ETI - Par OpinionWay...OpinionWay
 
Enterprise Mobility
Enterprise MobilityEnterprise Mobility
Enterprise MobilityYagmur Anish
 
Practica google calendar
Practica google calendarPractica google calendar
Practica google calendarfcacasas
 
Siagi - Autocensure et comportement des artisans en matière de financement - ...
Siagi - Autocensure et comportement des artisans en matière de financement - ...Siagi - Autocensure et comportement des artisans en matière de financement - ...
Siagi - Autocensure et comportement des artisans en matière de financement - ...OpinionWay
 
OpinionWay pour Quelle énergie - Les Français et le chauffage / Octobre 2016
OpinionWay pour Quelle énergie - Les Français et le chauffage / Octobre 2016OpinionWay pour Quelle énergie - Les Français et le chauffage / Octobre 2016
OpinionWay pour Quelle énergie - Les Français et le chauffage / Octobre 2016contactOpinionWay
 
OpinionWay - Solocal baromètre des avis des internautes / Novembre 2016
OpinionWay - Solocal baromètre des avis des internautes / Novembre 2016OpinionWay - Solocal baromètre des avis des internautes / Novembre 2016
OpinionWay - Solocal baromètre des avis des internautes / Novembre 2016contactOpinionWay
 
OpinionWay pour Foncière des Régions - Les Européens et l'hébergement de ...
OpinionWay pour Foncière des Régions - Les Européens et l'hébergement de ...OpinionWay pour Foncière des Régions - Les Européens et l'hébergement de ...
OpinionWay pour Foncière des Régions - Les Européens et l'hébergement de ...contactOpinionWay
 
A menina que nao gostava de fruta
A menina que nao gostava de frutaA menina que nao gostava de fruta
A menina que nao gostava de frutaAna Fausto
 
62556550 folclor-muzical
62556550 folclor-muzical62556550 folclor-muzical
62556550 folclor-muzicalJunoiu Oana
 
Plan de negocio grupo 113176
Plan de negocio grupo 113176Plan de negocio grupo 113176
Plan de negocio grupo 113176113176
 
Comment intégrer un questionnaire intelligent sur mon site web
Comment intégrer un questionnaire intelligent sur mon site webComment intégrer un questionnaire intelligent sur mon site web
Comment intégrer un questionnaire intelligent sur mon site webMyFeelBack
 
icEurope - das Projekt - Workshop
icEurope - das Projekt - WorkshopicEurope - das Projekt - Workshop
icEurope - das Projekt - WorkshopClaudia Warth
 
Présentation pwp glénic
Présentation pwp glénicPrésentation pwp glénic
Présentation pwp glénicpaysdegueret
 

En vedette (20)

Adobe captivate
Adobe captivateAdobe captivate
Adobe captivate
 
Freelance Workshop Lecture1
Freelance Workshop Lecture1Freelance Workshop Lecture1
Freelance Workshop Lecture1
 
Responses of phytoplankton to a changing climate
Responses of phytoplankton to a changing climateResponses of phytoplankton to a changing climate
Responses of phytoplankton to a changing climate
 
Presentacion3
Presentacion3Presentacion3
Presentacion3
 
Club der Freunde
Club der FreundeClub der Freunde
Club der Freunde
 
Banque Palatine / Opinionway : Observatoire de la performance des PME/ETI / J...
Banque Palatine / Opinionway : Observatoire de la performance des PME/ETI / J...Banque Palatine / Opinionway : Observatoire de la performance des PME/ETI / J...
Banque Palatine / Opinionway : Observatoire de la performance des PME/ETI / J...
 
Banque Palatine - Observatoire de la performance des PME-ETI - Par OpinionWay...
Banque Palatine - Observatoire de la performance des PME-ETI - Par OpinionWay...Banque Palatine - Observatoire de la performance des PME-ETI - Par OpinionWay...
Banque Palatine - Observatoire de la performance des PME-ETI - Par OpinionWay...
 
Enterprise Mobility
Enterprise MobilityEnterprise Mobility
Enterprise Mobility
 
Practica google calendar
Practica google calendarPractica google calendar
Practica google calendar
 
Siagi - Autocensure et comportement des artisans en matière de financement - ...
Siagi - Autocensure et comportement des artisans en matière de financement - ...Siagi - Autocensure et comportement des artisans en matière de financement - ...
Siagi - Autocensure et comportement des artisans en matière de financement - ...
 
OpinionWay pour Quelle énergie - Les Français et le chauffage / Octobre 2016
OpinionWay pour Quelle énergie - Les Français et le chauffage / Octobre 2016OpinionWay pour Quelle énergie - Les Français et le chauffage / Octobre 2016
OpinionWay pour Quelle énergie - Les Français et le chauffage / Octobre 2016
 
OpinionWay - Solocal baromètre des avis des internautes / Novembre 2016
OpinionWay - Solocal baromètre des avis des internautes / Novembre 2016OpinionWay - Solocal baromètre des avis des internautes / Novembre 2016
OpinionWay - Solocal baromètre des avis des internautes / Novembre 2016
 
OpinionWay pour Foncière des Régions - Les Européens et l'hébergement de ...
OpinionWay pour Foncière des Régions - Les Européens et l'hébergement de ...OpinionWay pour Foncière des Régions - Les Européens et l'hébergement de ...
OpinionWay pour Foncière des Régions - Les Européens et l'hébergement de ...
 
Taller fitoterapia1
Taller fitoterapia1Taller fitoterapia1
Taller fitoterapia1
 
A menina que nao gostava de fruta
A menina que nao gostava de frutaA menina que nao gostava de fruta
A menina que nao gostava de fruta
 
62556550 folclor-muzical
62556550 folclor-muzical62556550 folclor-muzical
62556550 folclor-muzical
 
Plan de negocio grupo 113176
Plan de negocio grupo 113176Plan de negocio grupo 113176
Plan de negocio grupo 113176
 
Comment intégrer un questionnaire intelligent sur mon site web
Comment intégrer un questionnaire intelligent sur mon site webComment intégrer un questionnaire intelligent sur mon site web
Comment intégrer un questionnaire intelligent sur mon site web
 
icEurope - das Projekt - Workshop
icEurope - das Projekt - WorkshopicEurope - das Projekt - Workshop
icEurope - das Projekt - Workshop
 
Présentation pwp glénic
Présentation pwp glénicPrésentation pwp glénic
Présentation pwp glénic
 

Similaire à Facebook API Document

Angular 11 google social login or sign in tutorial using angularx social-login
Angular 11 google social login or sign in tutorial using angularx social-loginAngular 11 google social login or sign in tutorial using angularx social-login
Angular 11 google social login or sign in tutorial using angularx social-loginKaty Slemon
 
Mobile 2.0 Open Ideas WorkShop: Building Social Media Enabled Apps on Android
Mobile 2.0 Open Ideas WorkShop: Building Social Media Enabled Apps on AndroidMobile 2.0 Open Ideas WorkShop: Building Social Media Enabled Apps on Android
Mobile 2.0 Open Ideas WorkShop: Building Social Media Enabled Apps on AndroidAlberto Ruibal
 
Foundational Facebook Marketing
Foundational Facebook MarketingFoundational Facebook Marketing
Foundational Facebook MarketingBlitzMetrics
 
Google external login setup in ASP (1).pdf
Google external login setup in ASP  (1).pdfGoogle external login setup in ASP  (1).pdf
Google external login setup in ASP (1).pdffindandsolve .com
 
How NOT to Suck at App Distribution - Quick Start Guide - Appsocially's Growt...
How NOT to Suck at App Distribution - Quick Start Guide - Appsocially's Growt...How NOT to Suck at App Distribution - Quick Start Guide - Appsocially's Growt...
How NOT to Suck at App Distribution - Quick Start Guide - Appsocially's Growt...Yusuke Takahashi, PhD
 
Cis407 a ilab 6 web application development devry university
Cis407 a ilab 6 web application development devry universityCis407 a ilab 6 web application development devry university
Cis407 a ilab 6 web application development devry universitylhkslkdh89009
 
Workshop : Facebook JavaScript SDK
Workshop : Facebook JavaScript SDKWorkshop : Facebook JavaScript SDK
Workshop : Facebook JavaScript SDKDimitar Danailov
 
Facebook SSO.docx
Facebook SSO.docxFacebook SSO.docx
Facebook SSO.docxehathis
 
Firebase Auth Tutorial
Firebase Auth TutorialFirebase Auth Tutorial
Firebase Auth TutorialBukhori Aqid
 
Jsf login logout project
Jsf login logout projectJsf login logout project
Jsf login logout projectGagandeep Singh
 
Plug in development
Plug in developmentPlug in development
Plug in developmentLucky Ali
 
Custom cell in objective c
Custom cell in objective cCustom cell in objective c
Custom cell in objective cVishal Verma
 
Tightly coupled view (model bounded view)
Tightly coupled view (model bounded view)Tightly coupled view (model bounded view)
Tightly coupled view (model bounded view)IT PROGRAMMING WORLD
 
Creating a content managed facebook app
Creating a content managed facebook appCreating a content managed facebook app
Creating a content managed facebook appOS-Cubed, Inc.
 
Full Angular 7 Firebase Authentication System
Full Angular 7 Firebase Authentication SystemFull Angular 7 Firebase Authentication System
Full Angular 7 Firebase Authentication SystemDigamber Singh
 

Similaire à Facebook API Document (20)

Angularjs Live Project
Angularjs Live ProjectAngularjs Live Project
Angularjs Live Project
 
Angular 11 google social login or sign in tutorial using angularx social-login
Angular 11 google social login or sign in tutorial using angularx social-loginAngular 11 google social login or sign in tutorial using angularx social-login
Angular 11 google social login or sign in tutorial using angularx social-login
 
Mobile 2.0 Open Ideas WorkShop: Building Social Media Enabled Apps on Android
Mobile 2.0 Open Ideas WorkShop: Building Social Media Enabled Apps on AndroidMobile 2.0 Open Ideas WorkShop: Building Social Media Enabled Apps on Android
Mobile 2.0 Open Ideas WorkShop: Building Social Media Enabled Apps on Android
 
Foundational Facebook Marketing
Foundational Facebook MarketingFoundational Facebook Marketing
Foundational Facebook Marketing
 
Google external login setup in ASP (1).pdf
Google external login setup in ASP  (1).pdfGoogle external login setup in ASP  (1).pdf
Google external login setup in ASP (1).pdf
 
Devise and Rails
Devise and RailsDevise and Rails
Devise and Rails
 
How NOT to Suck at App Distribution - Quick Start Guide - Appsocially's Growt...
How NOT to Suck at App Distribution - Quick Start Guide - Appsocially's Growt...How NOT to Suck at App Distribution - Quick Start Guide - Appsocially's Growt...
How NOT to Suck at App Distribution - Quick Start Guide - Appsocially's Growt...
 
Cis407 a ilab 6 web application development devry university
Cis407 a ilab 6 web application development devry universityCis407 a ilab 6 web application development devry university
Cis407 a ilab 6 web application development devry university
 
Workshop : Facebook JavaScript SDK
Workshop : Facebook JavaScript SDKWorkshop : Facebook JavaScript SDK
Workshop : Facebook JavaScript SDK
 
Facebook SSO.docx
Facebook SSO.docxFacebook SSO.docx
Facebook SSO.docx
 
Firebase Auth Tutorial
Firebase Auth TutorialFirebase Auth Tutorial
Firebase Auth Tutorial
 
Jsf login logout project
Jsf login logout projectJsf login logout project
Jsf login logout project
 
Plug in development
Plug in developmentPlug in development
Plug in development
 
Custom cell in objective c
Custom cell in objective cCustom cell in objective c
Custom cell in objective c
 
Tightly coupled view (model bounded view)
Tightly coupled view (model bounded view)Tightly coupled view (model bounded view)
Tightly coupled view (model bounded view)
 
Creating a content managed facebook app
Creating a content managed facebook appCreating a content managed facebook app
Creating a content managed facebook app
 
Full Angular 7 Firebase Authentication System
Full Angular 7 Firebase Authentication SystemFull Angular 7 Firebase Authentication System
Full Angular 7 Firebase Authentication System
 
Yii php framework_honey
Yii php framework_honeyYii php framework_honey
Yii php framework_honey
 
Iphone course 3
Iphone course 3Iphone course 3
Iphone course 3
 
Cloud Messaging Flutter
Cloud Messaging FlutterCloud Messaging Flutter
Cloud Messaging Flutter
 

Plus de Sangon Lee

NoSQL Guide & Sample
NoSQL Guide &  SampleNoSQL Guide &  Sample
NoSQL Guide & SampleSangon Lee
 
Android ndk jni 설치및 연동
Android ndk jni 설치및 연동Android ndk jni 설치및 연동
Android ndk jni 설치및 연동Sangon Lee
 
Android xml parsing
Android xml parsingAndroid xml parsing
Android xml parsingSangon Lee
 
Naver api for android
Naver api for androidNaver api for android
Naver api for androidSangon Lee
 
Android 기초강좌 애플리캐이션 구조
Android 기초강좌 애플리캐이션 구조Android 기초강좌 애플리캐이션 구조
Android 기초강좌 애플리캐이션 구조Sangon Lee
 
번역돋보기 기획서
번역돋보기 기획서번역돋보기 기획서
번역돋보기 기획서Sangon Lee
 
Storyboard iOS 개발실습예제
Storyboard iOS 개발실습예제Storyboard iOS 개발실습예제
Storyboard iOS 개발실습예제Sangon Lee
 
17. cocos2d 기초
17. cocos2d  기초17. cocos2d  기초
17. cocos2d 기초Sangon Lee
 

Plus de Sangon Lee (10)

NoSQL Guide & Sample
NoSQL Guide &  SampleNoSQL Guide &  Sample
NoSQL Guide & Sample
 
Gcd ppt
Gcd pptGcd ppt
Gcd ppt
 
Android ndk jni 설치및 연동
Android ndk jni 설치및 연동Android ndk jni 설치및 연동
Android ndk jni 설치및 연동
 
Android xml parsing
Android xml parsingAndroid xml parsing
Android xml parsing
 
Naver api for android
Naver api for androidNaver api for android
Naver api for android
 
Android 기초강좌 애플리캐이션 구조
Android 기초강좌 애플리캐이션 구조Android 기초강좌 애플리캐이션 구조
Android 기초강좌 애플리캐이션 구조
 
번역돋보기 기획서
번역돋보기 기획서번역돋보기 기획서
번역돋보기 기획서
 
StudyShare
StudyShareStudyShare
StudyShare
 
Storyboard iOS 개발실습예제
Storyboard iOS 개발실습예제Storyboard iOS 개발실습예제
Storyboard iOS 개발실습예제
 
17. cocos2d 기초
17. cocos2d  기초17. cocos2d  기초
17. cocos2d 기초
 

Dernier

So einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdfSo einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdfpanagenda
 
A Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersA Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersNicole Novielli
 
Decarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a realityDecarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a realityIES VE
 
Emixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native developmentEmixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native developmentPim van der Noll
 
Bridging Between CAD & GIS: 6 Ways to Automate Your Data Integration
Bridging Between CAD & GIS:  6 Ways to Automate Your Data IntegrationBridging Between CAD & GIS:  6 Ways to Automate Your Data Integration
Bridging Between CAD & GIS: 6 Ways to Automate Your Data Integrationmarketing932765
 
Top 10 Hubspot Development Companies in 2024
Top 10 Hubspot Development Companies in 2024Top 10 Hubspot Development Companies in 2024
Top 10 Hubspot Development Companies in 2024TopCSSGallery
 
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24Mark Goldstein
 
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyesHow to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyesThousandEyes
 
Design pattern talk by Kaya Weers - 2024 (v2)
Design pattern talk by Kaya Weers - 2024 (v2)Design pattern talk by Kaya Weers - 2024 (v2)
Design pattern talk by Kaya Weers - 2024 (v2)Kaya Weers
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxLoriGlavin3
 
Abdul Kader Baba- Managing Cybersecurity Risks and Compliance Requirements i...
Abdul Kader Baba- Managing Cybersecurity Risks  and Compliance Requirements i...Abdul Kader Baba- Managing Cybersecurity Risks  and Compliance Requirements i...
Abdul Kader Baba- Managing Cybersecurity Risks and Compliance Requirements i...itnewsafrica
 
Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...
Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...
Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...Nikki Chapple
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024BookNet Canada
 
Long journey of Ruby standard library at RubyConf AU 2024
Long journey of Ruby standard library at RubyConf AU 2024Long journey of Ruby standard library at RubyConf AU 2024
Long journey of Ruby standard library at RubyConf AU 2024Hiroshi SHIBATA
 
Zeshan Sattar- Assessing the skill requirements and industry expectations for...
Zeshan Sattar- Assessing the skill requirements and industry expectations for...Zeshan Sattar- Assessing the skill requirements and industry expectations for...
Zeshan Sattar- Assessing the skill requirements and industry expectations for...itnewsafrica
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc
 
Potential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and InsightsPotential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and InsightsRavi Sanghani
 
MuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotes
MuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotesMuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotes
MuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotesManik S Magar
 
Time Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsTime Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsNathaniel Shimoni
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxLoriGlavin3
 

Dernier (20)

So einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdfSo einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdf
 
A Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersA Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software Developers
 
Decarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a realityDecarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a reality
 
Emixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native developmentEmixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native development
 
Bridging Between CAD & GIS: 6 Ways to Automate Your Data Integration
Bridging Between CAD & GIS:  6 Ways to Automate Your Data IntegrationBridging Between CAD & GIS:  6 Ways to Automate Your Data Integration
Bridging Between CAD & GIS: 6 Ways to Automate Your Data Integration
 
Top 10 Hubspot Development Companies in 2024
Top 10 Hubspot Development Companies in 2024Top 10 Hubspot Development Companies in 2024
Top 10 Hubspot Development Companies in 2024
 
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
 
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyesHow to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
 
Design pattern talk by Kaya Weers - 2024 (v2)
Design pattern talk by Kaya Weers - 2024 (v2)Design pattern talk by Kaya Weers - 2024 (v2)
Design pattern talk by Kaya Weers - 2024 (v2)
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
 
Abdul Kader Baba- Managing Cybersecurity Risks and Compliance Requirements i...
Abdul Kader Baba- Managing Cybersecurity Risks  and Compliance Requirements i...Abdul Kader Baba- Managing Cybersecurity Risks  and Compliance Requirements i...
Abdul Kader Baba- Managing Cybersecurity Risks and Compliance Requirements i...
 
Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...
Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...
Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
 
Long journey of Ruby standard library at RubyConf AU 2024
Long journey of Ruby standard library at RubyConf AU 2024Long journey of Ruby standard library at RubyConf AU 2024
Long journey of Ruby standard library at RubyConf AU 2024
 
Zeshan Sattar- Assessing the skill requirements and industry expectations for...
Zeshan Sattar- Assessing the skill requirements and industry expectations for...Zeshan Sattar- Assessing the skill requirements and industry expectations for...
Zeshan Sattar- Assessing the skill requirements and industry expectations for...
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
 
Potential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and InsightsPotential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and Insights
 
MuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotes
MuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotesMuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotes
MuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotes
 
Time Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsTime Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directions
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
 

Facebook API Document

  • 1. FaceBook OPEN API - Grahp Story- Develop S.O.Lab by 이상온
  • 2. Face Book API 3 TPYE WebSite 안에서 Face Book 연동 Api 모바일 단말기에서 Face Book 연동앱개발 facebook.com 내의 앱개발
  • 4. 목차 1. Facebook SDK install 2. Run the sample 3. Create Facebook App 4. Start new X-code Project 5. FACEBOOK Login & Authenticate 6. Personalize 7. Show Friends 8. Show Nearby Places 9. Publish to Feed
  • 5. Step 1: Facebook SDK install Facebook SDK install
  • 6. Step 1: Facebook SDK install
  • 7. Step 2: Run the sample Basic samples • HelloFacebookSample: combines use of FBLoginView, FBProfilePictureView, FBFriendsPickerViewController, FBPlacePickerViewController, and FBRequest for profile access, status updates and photo uploading. • ProfilePictureSample: demonstrates non-logged-in usage of the FBProfilePictureView control. • FriendPickerSample: demonstrates usage of the native multi-friend selector control to choose amongst the logged-in users' friends. • PlacePickerSample: demonstrates logged-in usage of the FBPlacePickerView control. More in-depth single feature samples • SessionLoginSample: demonstrates detailed login flow via FBSession. • JustRequestSample: demonstrates logged in user making a request of Facebook via FBRequest and FBRequestConnection, including batched requests. • BooleanOGSample: demonstrates publishing an Open Graph custom action type. More complete and special-case samples • Scrumptious: integrated sample app demonstrating the use of login, requests, Place Picker, Friend Picker, Picture Upload, and Open Graph Publishing. • SwitchUserSample: demonstrates an approach to allow switching logins between multiple users - for example, on a shared family iPad.
  • 8. Step 3: Create Facebook App 앱ID/API Key 앱 시크릿코드
  • 9. Step 4: Start new X-code Project
  • 10. Step 4: Start new X-code Project
  • 11. Step 4: Start new X-code Project Add the Facebook SDK for iOS Framework by dragging the FacebookSDK.frameworkfolder from the SDK installation folder into the Frameworks section of your Project Navigator.
  • 12. Step 4: Start new X-code Project Add the Facebook SDK for iOS resource bundle by dragging theFacebookSDKResources.bundle file from theFacebookSDK.framework/ Resources folder into the Frameworks section of your Project Navigator.
  • 13. Step 4: Start new X-code Project Add the ''-lsqlite3.0'' SQL library to the list of build dependencies
  • 14. Step 4: Start new X-code Project Finally, you need to place the Facebook app ID in two places in your application's main.plist file. Create a key called FacebookAppID with a string value, and add the app ID there: 250959118344050
  • 15. Step 4: Start new X-code Project Also, create an array key called URL types with a single array sub-item called URL Schemes. Give this a single item with your app ID prefixed with fb: This is used to ensure the application will receive the callback URL of the web-based OAuth flow.
  • 16. Step 5: FACEBOOK Login & Authenticate FBsession 객체 : login & Authorize manage • sessionOpenWithPermissions:completionHandler: 함수를 호출하여 퍼미션를 선언하고 세션인증을 받을 콜백 핸들러를 제공 한다. • Facebook App으로부터 받을 핸들러 구성 • login or error 에대한 콜백핸들러 구현 MyAppViewController : 로그인 후 FBLoginViewController : 로그인 전
  • 17. Step 5: FACEBOOK Login & Authenticate New File > Object-c class > FBLoginViewController xib 파일에서 Button & Activity Indicator 추가
  • 18. Step 5: FACEBOOK Login & Authenticate 한번 로그인 성공하고 나면 MYAppViewController 를 보여줄 것이다. 앱이 실행되면 먼저 저장되어있는 session를 체크하여 로그인/로그아웃 화면을 선택 한다. 실질적인 메인화면은 MyAppviewController 가 될것이며 FBLoginViewConroller는 필요할때만 모달로 나타날 것이다. 1. AppDelegate.m 파일에 해더 추가 #import <FacebookSDK/FacebookSDK.h> 2. AppDelegate.m 파일에 FBLoginViewController 파일추가 #import “FBLoginViewController“
  • 19. Step 5: FACEBOOK Login & Authenticate 3.로그인뷰가 모달로 보여질것임으로,, MyAppViewController needs to be part of a UINavigationController. AppDelegate.h 파일에 new navigation controller 선언 @interface MyAppDelegate () @property (strong, nonatomic) UINavigationController* navController; @end 4. AppDelegate.m 파일에 Synthesize this new property @synthesize navController = _navController;
  • 20. Step 5: FACEBOOK Login & Authenticate 5. AppDelegate.h 파일에 생성시 기본으로 만들어진 @property (strong, nonatomic) MyAppViewController *viewController; 를 @property (strong, nonatomic) MyAppViewController *mainViewController; 로 고친다 6. AppDelegate.m 파일에 modify the synthesized property to have the new name by changing: @synthesize mainViewController = _mainViewController;
  • 21. Step 5: FACEBOOK Login & Authenticate 7. application:didFinishLaunchingWithOptions: method, change this code: self.mainViewController = [[MyAppViewController alloc] initWithNibName:@"MyAppViewController_iPhone" bundle:nil]; self.navController = [[UINavigationController alloc] initWithRootViewController:self.mainViewController]; self.window.rootViewController = self.navController; 8. AppDelegate.m 파일에 로그인뷰 보여줄 함수 구현 - (void)showLoginView { UIViewController *topViewController = [self.navController topViewController]; FBLoginViewController* loginViewController = [[FBLoginViewController alloc]initWithNibName:@"FBLoginViewController" bundle:nil]; [topViewController presentModalViewController:loginViewController animated:NO]; }
  • 22. Step 5: FACEBOOK Login & Authenticate 9. application:didFinishLaunchingWithOptions: method, change this code: FBSession을 채크하여 로그인화면 보여줄것인지 판단한는 함수 추가 // See if we have a valid token for the current state. if (FBSession.activeSession.state == FBSessionStateCreatedTokenLoaded) { // To-do, show logged in view } else { // No, display the login page. [self showLoginView]; } - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]]; self.mainViewController = [[MyAppViewController alloc] initWithNibName:@"MyAppViewController_iPhone" bundle:nil]; self.navController = [[UINavigationController alloc] initWithRootViewController:self.mainViewController]; self.window.rootViewController = self.navController; [self.window makeKeyAndVisible]; if (FBSession.activeSession.state == FBSessionStateCreatedTokenLoaded) { // To-do, show logged in view } else { // No, display the login page. [self showLoginView]; } return YES; }
  • 23. Step 5: FACEBOOK Login & Authenticate 10. FBLoginViewController.xib attach an action to the login button & outlet to the activity indicator IN FBLoginViewController.m
  • 24. Step 5: FACEBOOK Login & Authenticate
  • 25. Step 5: FACEBOOK Login & Authenticate 11. AppDelegate.m 파일에서 openSession 이라는 공용 메소드를 등록하고 login버튼을 클릭시 이함수를 호출한다. - (void)openSession { [FBSession openActiveSessionWithPermissions:nil allowLoginUI:YES completionHandler: ^(FBSession *session, FBSessionState state, NSError *error) { [self sessionStateChanged:session state:state error:error]; }]; }
  • 26. Step 5: FACEBOOK Login & Authenticate 12. AppDelegate.m 파일에서 sessionStateChanged: state: error:이라는 메소드를 등록 - (void)sessionStateChanged:(FBSession *)session state:(FBSessionState) state error:(NSError *)error { switch (state) { case FBSessionStateOpen: { UIViewController *topViewController =[self.navController topViewController]; if ([[topViewController modalViewController] isKindOfClass:[FBLoginViewController class]]) { [topViewController dismissModalViewControllerAnimated:YES]; } } break; case FBSessionStateClosed: case FBSessionStateClosedLoginFailed: [self.navController popToRootViewControllerAnimated:NO]; [FBSession.activeSession closeAndClearTokenInformation]; [self showLoginView]; break; default: break; } if (error) { UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"Error" message:error.localizedDescription delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil]; [alertView show]; } }
  • 27. Step 5: FACEBOOK Login & Authenticate 13. application:didFinishLaunchingWithOptions: method, change this code: // See if we have a valid token for the current state. if (FBSession.activeSession.state == FBSessionStateCreatedTokenLoaded) { // To-do, show logged in view [self openSession]; } else { // No, display the login page. [self showLoginView]; } 14. App Delegate .h 파일에 함수 선언 추가 - (void)openSession;
  • 28. Step 5: FACEBOOK Login & Authenticate 15. FBLoginViewController.m 파일에 import #import "MyAppDelegate.h" 16. FBLoginViewController.m - (IBAction)performLogin:(id)sender 함수 구 현 - (IBAction)performLogin:(id)sender { [self.spinner startAnimating]; SCAppDelegate* appDelegate = [UIApplication sharedApplication].delegate; [appDelegate openSession]; }
  • 29. Step 5: FACEBOOK Login & Authenticate 17. FBLoginViewController.m - (void)loginFailed; 함수 구현 - (void)loginFailed { // User switched back to the app without authorizing. Stay here, but // stop the spinner. [self.spinner stopAnimating]; } 18. FBLoginViewController.h - (void)loginFailed; 함수 선언 - (void)loginFailed;
  • 30. Step 5: FACEBOOK Login & Authenticate 19. AppDelegate.m 파일의 showLoginView 함수를 수정 - (void)showLoginView { NSLog(@"showLoginView ~~함수 호출"); UIViewController *topViewController = [self.navController topViewController]; /* FBLoginViewController* loginViewController = [[FBLoginViewController alloc] initWithNibName:@"FBLoginViewController" bundle:nil]; [topViewController presentModalViewController:loginViewController animated:NO]; */ UIViewController *modalViewController = [topViewController modalViewController]; if (![modalViewController isKindOfClass:[FBLoginViewController class]]) { FBLoginViewController* loginViewController = [[FBLoginViewController alloc] initWithNibName:@"FBLoginViewController" bundle:nil]; [topViewController presentModalViewController:loginViewController animated:NO]; } else { FBLoginViewController* loginViewController = (FBLoginViewController*)modalViewController; [loginViewController loginFailed]; } }
  • 31. Step 5: FACEBOOK Login & Authenticate 20. Facebook 에 로그인하는동안 App 이나 safari를 통해 컨트롤을 보내고 인증 받은 후에 session 정보를 받아온다. 이것을 수행하는 (BOOL)application:(UIApplication *)application openURL 함수를 AppDelegate.m 파일에 구현 - (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation { return [FBSession.activeSession handleOpenURL:url]; } 21. Facebook 인증중에 사용자가 폰을종료시켜버릴경우 세션도 종료시켜야 함 으로 applicationDidBecomeActive: delegate 메소드에 다음을 추가한다. if (FBSession.activeSession.state == FBSessionStateCreatedOpening) { [FBSession.activeSession close]; // so we close our session and start over }
  • 32. Step 5: FACEBOOK Login & Authenticate 22. MyAppViewController.m 파일에 해더를 추가 #import <FacebookSDK/FacebookSDK.h> 23. MyAppViewController.m 파일의 viewDidLoad 함수에 추가 self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"Logout" style:UIBarButtonItemStyleBordered target:self action:@selector(logoutButtonWasPressed:)]; 24. MyAppViewController.m 파일의 logoutButtonWasPressed 함수에 추가 -(void)logoutButtonWasPressed:(id)sender { [FBSession.activeSession closeAndClearTokenInformation]; }
  • 33. Step 6: Personalize displaying the user's profile picture and name when they've authenticated. 1) Facebook SDK FBRequest object 2) activeSession on FBSession has been opened, or else provide an explicit FBSession instance to the FBRequestcalls. 3) requestForMeWithSession that returns an FBRequestobject 4) The user data will be a strongly typed FBGraphUser object 5) Once you've constructed an FBRequest object, you can initiate the API call by invoking thestartWithCompletionHandler: method. View 추가후 class 를 FBProfilePictureView로 셋팅 XIB 객체선택후 ctl + 드레그 to 소스코드
  • 34. Step 6: Personalize
  • 35. Step 6: Personalize User info Display function구현 - (void)populateUserDetails { if (FBSession.activeSession.isOpen) { [[FBRequest requestForMe] startWithCompletionHandler: ^(FBRequestConnection *connection, NSDictionary<FBGraphUser> *user, NSError *error) { if (!error) { self.userNameLabel.text = user.name; self.userProfileImage.profileID = user.id; } }]; } } 이함수가 성공적으로 실행되면 FBProfilePictureView 객체의 Property에 정보를 셋팅한다.
  • 36. Step 6: Personalize 로그인 상태에서 정보를 바로 보여주기위한 function구현 -(void)viewWillAppear:(BOOL)animated{ [super viewWillAppear:animated]; if (FBSession.activeSession.isOpen) { [self populateUserDetails]; } } 페이지 로딩시 이함수가 실행되면서 사용자정보를 바로 보여준다.
  • 37. Step 6: Personalize 업데이트된 사용자 정보를 어느때나 보고 싶다면 Active Session이 바뀔때마다 NSNotificationCenter를 notified하여 제공할수 있다. 1.AppDelegate.h 파일에 다음을 선언한다. extern NSString *const SCSessionStateChangedNotification; 2.AppDelegate.m 파일에 다음을 추가한다. NSString *const SCSessionStateChangedNotification = @"com.solab.FaceBookApiFirst:FBSessionStateChangedNotification";
  • 38. Step 6: Personalize 1.AppDelegate.m 파일의 -(void)sessionStateChanged:(FBSession *)session 함수안에 notification을 추가하여 세션변경때마다 호출한다. - (void)sessionStateChanged:(FBSession *)session state:(FBSessionState) state error:(NSError *)error { switch (state) { case FBSessionStateOpen: { UIViewController *topViewController = [self.navController topViewController]; if ([[topViewController modalViewController] isKindOfClass:[FBLoginViewController class]]) { [topViewController dismissModalViewControllerAnimated:YES]; } } break; case FBSessionStateClosed: case FBSessionStateClosedLoginFailed: // Once the user has logged in, we want them to // be looking at the root view. [self.navController popToRootViewControllerAnimated:NO]; [FBSession.activeSession closeAndClearTokenInformation]; [self showLoginView]; break; default: break; } [[NSNotificationCenter defaultCenter] postNotificationName:FBSessionStateChangedNotification object:session]; if (error) { UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"Error" message:error.localizedDescription delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil]; [alertView show]; } }
  • 39. Step 6: Personalize 1.오류 수정 2012-05-18 04:04:11.620 Scrumptious[6548:f803] Unknown class FBProfilePictureView in Interface Builder file. add this as the first line in the app delegate's application:didFinishLaunchingWit hOptions:method: [FBProfilePictureView class];
  • 40. Step 7: Show Friends 1.Facebook 친구들의 정보를 가져오기 위해서는 FBFriendPickerViewController 객체를 이용하면 된다. 2.FBFriendPickerViewController 을 사용하기 위해서는 initWithNibName:bundle: 함수 안에서 객체를 생성한다. 3.FBFriendPickerDelegate notifications 객체를 정의하기위한 델이게이트 메소드 를 셋팅한다. 4.마지막으로 loadData 함수를 호출하면 FBFriendPickerViewController에 친구 정보가 보여진다. FBFriendPickerDelegate friendPickerViewControllerSelectionDidChange: FBFriendPickerViewController selection property
  • 41. Step 7: Show Friends 1.Set Up the User Interface Add a Table View object Style: Grouped; Show Selection on Touch: NO; Scrolling Enabled: NO; • Create an outlet for the Table View object and call it menuTableView. • Connect the dataSource outlet to the File's Owner. • Connect the delegate outlet to the File's Owner.
  • 42. Step 7: Show Friends 1.Set Up The Menu Display MyAppViewController.m 파일에 선언 @interface SCViewController () <UITableViewDataSource,UITableViewDelegate> MyAppViewController.m 파일에 TableView delegate 구현 - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString *CellIdentifier = @"Cell"; UITableViewCell *cell = (UITableViewCell*)[tableView dequeueReusableCellWithIdentifier:CellIdentifier]; if (cell == nil) { cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier]; cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator; cell.selectionStyle = UITableViewCellSelectionStyleNone;
  • 43. Step 7: Show Friends cell.textLabel.font = [UIFont systemFontOfSize:16]; cell.textLabel.backgroundColor = [UIColor colorWithWhite:0 alpha:0]; cell.textLabel.lineBreakMode = UILineBreakModeTailTruncation; cell.textLabel.clipsToBounds = YES; cell.detailTextLabel.font = [UIFont systemFontOfSize:12]; cell.detailTextLabel.backgroundColor = [UIColor colorWithWhite:0 alpha:0]; cell.detailTextLabel.textColor = [UIColor colorWithRed:0.4 green:0.6 blue:0.8 alpha:1]; cell.detailTextLabel.lineBreakMode = UILineBreakModeTailTruncation; cell.detailTextLabel.clipsToBounds = YES; } switch (indexPath.row) { case 0: cell.textLabel.text = @"What are you eating?"; cell.detailTextLabel.text = @"Select one"; cell.imageView.image = [UIImage imageNamed:@"action-eating.png"]; break; case 1: cell.textLabel.text = @"Where are you?"; cell.detailTextLabel.text = @"Select one"; cell.imageView.image = [UIImage imageNamed:@"action-location.png"]; break;
  • 44. Step 7: Show Friends case 2: cell.textLabel.text = @"With whom?"; cell.detailTextLabel.text = @"Select friends"; cell.imageView.image = [UIImage imageNamed:@"action-people.png"]; break; case 3: cell.textLabel.text = @"Got a picture?"; cell.detailTextLabel.text = @"Take one"; cell.imageView.image = [UIImage imageNamed:@"action-photo.png"]; break; default: break; } return cell; }
  • 45. Step 7: Show Friends - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { return 4; } - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { return 1; } - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { // Do nothing for now }
  • 46. Step 7: Show Friends 1.Show the Friend Selector MyAppViewController.m 파일에 추가 @property (strong, nonatomic) FBFriendPickerViewController *friendPickerController; @synthesize friendPickerController = _friendPickerController; ViewdidUnLoad 함수에 추가 self.friendPickerController = nil;
  • 47. Step 7: Show Friends tableView:didSelectRowAtIndexPath: 델리게이트 함수를 수정 - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { switch (indexPath.row) { case 2: if (!self.friendPickerController) { self.friendPickerController = [[FBFriendPickerViewController alloc] initWithNibName:nil bundle:nil]; self.friendPickerController.title = @"Select friends"; } [self.friendPickerController loadData]; [self.navigationController pushViewController:self.friendPickerController animated:true]; } }
  • 48. Step 7: Show Friends
  • 49. Step 7: Show Friends 1.Display Selected Friends tableView:didSelectRowAtIndexPath: 함수에 다음 코드를 추가 한다. self.friendPickerController.delegate = self; Add the dealloc method - (void)dealloc { _friendPickerController.delegate = nil; }
  • 50. Step 7: Show Friends 1.Display Selected Friends @property (strong, nonatomic) NSArray* selectedFriends; @synthesize selectedFriends = _selectedFriends; - (void)updateCellIndex:(int)index withSubtitle:(NSString*)subtitle { UITableViewCell *cell = (UITableViewCell *)[self.menuTableView cellForRowAtIndexPath:[NSIndexPath indexPathForRow:index inSection:0]]; cell.detailTextLabel.text = subtitle; }
  • 51. Step 7: Show Friends - (void)updateSelections { NSString* friendsSubtitle = @"Select friends"; int friendCount = self.selectedFriends.count; if (friendCount > 2) { // Just to mix things up, don't always show the first friend. id<FBGraphUser> randomFriend = [self.selectedFriends objectAtIndex:arc4random() % friendCount]; friendsSubtitle = [NSString stringWithFormat:@"%@ and %d others", randomFriend.name, friendCount - 1]; } else if (friendCount == 2) { id<FBGraphUser> friend1 = [self.selectedFriends objectAtIndex:0]; id<FBGraphUser> friend2 = [self.selectedFriends objectAtIndex:1]; friendsSubtitle = [NSString stringWithFormat:@"%@ and %@", friend1.name, friend2.name]; } else if (friendCount == 1) { id<FBGraphUser> friend = [self.selectedFriends objectAtIndex:0]; friendsSubtitle = friend.name; } [self updateCellIndex:2 withSubtitle:friendsSubtitle]; }
  • 52. Step 7: Show Friends Implement the FBFriendPickerDelegate method that will be notified of a friend selection - (void)friendPickerViewControllerSelectionDidChange: (FBFriendPickerViewController *)friendPicker { self.selectedFriends = friendPicker.selection; [self updateSelections]; }
  • 53. Step 7: Show Friends
  • 54. Step 8: Show Nearby Places 1.Facebook 친구들의 정보를 가져오기 위해서는 FBPlacePickerViewController 객체를 이용하면 된다. 2.FBFriendPickerViewController 을 사용하기 위해서는 initWithNibName:bundle: 함수 안에서 객체를 생성한다. 3.FBPlacePickerDelegate notifications 객체를 정의하기위한 델이게이트 메소드 를 셋팅한다. 4.마지막으로 loadData 함수를 호출하면 FBFriendPickerViewController에 친구 정보가 보여진다. FBPlacePickerDelegate placePickerViewControllerSelectionDidChange: FBPlacePickerViewController selection property FBGraphPlace
  • 55. Step 8: Show Nearby Places 1.Add the Core Location Framework
  • 56. Step 8: Show Nearby Places 1.Get the User's Current Location MyAppViewController.m 파일에 추가 @property (strong, nonatomic) CLLocationManager *locationManager; @synthesize locationManager = _locationManager; viewDidLoad 함수에 추가 self.locationManager = [[CLLocationManager alloc] init]; self.locationManager.delegate = self; self.locationManager.desiredAccuracy = kCLLocationAccuracyNearestTenMeters; self.locationManager.distanceFilter = 50; [self.locationManager startUpdatingLocation];
  • 57. Step 8: Show Nearby Places 1.Get the User's Current Location MyAppViewController.m 파일에 추가 - (void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation { if (!oldLocation || (oldLocation.coordinate.latitude != newLocation.coordinate.latitude && oldLocation.coordinate.longitude != newLocation.coordinate.longitude)) { // To-do, add code for triggering view controller update NSLog(@"Got location: %f, %f", newLocation.coordinate.latitude, newLocation.coordinate.longitude); } } - (void)locationManager:(CLLocationManager *)manager didFailWithError:(NSError *)error { NSLog(@"%@", error); }
  • 58. Step 8: Show Nearby Places 1.Show the Nearby Place Selector MyAppViewController.m 파일에 추가 @property (strong, nonatomic) FBPlacePickerViewController *placePickerController; @synthesize placePickerController = _placePickerController; tableView:didDeselectRowAtIndexPath 함수에 다음을 추가 case 1: if (!self.placePickerController) { self.placePickerController = [[FBPlacePickerViewController alloc] initWithNibName:nil bundle:nil]; self.placePickerController.title = @"Select a restaurant"; } self.placePickerController.locationCoordinate = self.locationManager.location.coordinate; self.placePickerController.radiusInMeters = 1000; self.placePickerController.resultsLimit = 50; self.placePickerController.searchText = @"restaurant"; [self.placePickerController loadData]; [self.navigationController pushViewController:self.placePickerController animated:true]; break;
  • 59. Step 8: Show Nearby Places
  • 60. Step 8: Show Nearby Places 1.Display the Selected Place tableView:didSelectRowAtIndexPath 메소드 수정 self.placePickerController.delegate = self; MyAppviewController.m 에 다음을 추가 @property (strong, nonatomic) NSObject<FBGraphPlace>* selectedPlace; @synthesize selectedPlace = _selectedPlace; updateSelections 함수에 다음을 추가 [self updateCellIndex:1 withSubtitle:(self.selectedPlace ? self.selectedPlace.name : @"Select One")];
  • 61. Step 8: Show Nearby Places FBPlacePickerDelegate 메소드 구현 - (void)placePickerViewControllerSelectionDidChange: (FBPlacePickerViewController *)placePicker { self.selectedPlace = placePicker.selection; [self updateSelections]; if (self.selectedPlace.count > 0) { [self.navigationController popViewControllerAnimated:true]; } }
  • 62. Step 9 : Publish to Feed 1.Facebook Timeline 의 구현을 Graph API를 사용하지 않고 대안으로 구현할수있는 Feed Dialog 방법을 설명한다. 2. FBRequestConnection 클래스를 이용한다. 3. startWithGraphPath:parameters:HTTPMethod:completionHandler: 함수를 사용한다. 4. USER_ID/feed 파라미터를 통하여 전달한다. 1: Set Up the Share View Trigger
  • 63. Step 9 : Publish to Feed 1: Set Up the Share View Trigger MyAppViewController.m 파일의 ViewDidLoad함수의 내용과 sessionStateChanged 함수의 내용을 변경 - (void)viewDidLoad { [super viewDidLoad]; // Do any additional setup after loading the view, typically from a nib. _loginButton = [UIButton buttonWithType:UIButtonTypeRoundedRect]; [_loginButton setTitle:@"Publish" forState:UIControlStateNormal]; _loginButton.frame = CGRectMake(80, 350, 150, 50); [_loginButton addTarget:self action:@selector(gofacebookpublish) forControlEvents:UIControlEventTouchUpInside]; [self.view addSubview:_loginButton]; - (void)sessionStateChanged:(NSNotification*)notification { if (FBSession.activeSession.isOpen) { self.loginButton.hidden = NO; } else { self.loginButton.hidden = YES; } [self populateUserDetails]; }
  • 64. Step 9 : Publish to Feed 2: Ask for Publish Permissions AppDelegate.m 파일의 함수에서 퍼미션을 설정한다. - (void)openSession { NSArray *permissions = [[NSArray alloc] initWithObjects: @"publish_actions", nil]; [FBSession openActiveSessionWithPermissions:permissions allowLoginUI:YES completionHandler: ^(FBSession *session, FBSessionState state, NSError *error) { [self sessionStateChanged:session state:state error:error]; }]; }
  • 65. Step 9 : Publish to Feed 3: Set Up the Share View 3-1. FBFeedViewcontroller 새로 생성
  • 66. Step 9 : Publish to Feed 3: Set Up the Share View 3-2. FBFeedViewController.xib 파일에서 .m 파일로 드러그앤 코딩으로 Tool bar 구현한다.
  • 67. Step 9 : Publish to Feed 3: Set Up the Share View 3-3. FBFeedViewController.xib 파일에서 .m 파일로 드러그앤 코딩으로 나머지 구현한다. Message: • Add a Text View object to the view below the toolbar. Stretch it out to take up most of the view's width. • In the Connections Inspector, connect the delegate outlet to the File's Owner. • Add an outlet to your view controller's implementation file so it's private. Name the outlet ''postMessageTextView''. Image: • Add an Image View object to the view below the ''Message'' text view, to the left of the main view. • In the Attributes Inspector, set the View > Mode to Aspect Fit. • In the Size Inspector, set the width to 80 and the height to 80. • Add an outlet to your view controller's implementation file so it's private. Name the outlet ''postImageView''. Name: • In the Attributes Inspector, set the text color to a dark blue and the font to System Bold. • Add an outlet to your view controller's implementation file so it's private. Name the outlet ''postNameLabel''. Caption: • Add a Label object to the view. Place it below the ''Name'' label. • In the Attributes Inspector, set the text color to a dark gray and the make the font size smaller than the ''Name'' label. Set the Lines attribute to 0. • Add an outlet to your view controller's implementation file so it's private. Name the outlet ''postCaptionLabel''. Description: • Add a Label object to the view. Place it below the ''Caption'' label. • In the Attributes Inspector, set the font size to be smaller than the ''Name'' label font size. Set the Lines attribute to 0. • Add an outlet to your view controller's implementation file so it's private. Name the outlet ''postDescriptionLabel''.
  • 68. Step 9 : Publish to Feed 3: Set Up the Share View 3-3. FBFeedViewController.xib 파일에서 .m 파일로 드러그앤 코딩으로 나머지 구현한다.
  • 69. Step 9 : Publish to Feed 3: Set Up the Share View 3-3. FBFeedViewController.m 코딩 text view에 미리 쓰여질 문자열 설정 text view에 미리 쓰여질 문자열 함수 구현
  • 70. Step 9 : Publish to Feed 3: Set Up the Share View 3-3. FBFeedViewController.m 코딩 UITextViewDelegate 메스드 구현
  • 71. Step 9 : Publish to Feed 3: Set Up the Share View 3-4. Configure the Display Data initWithNibName:bundle 메소드에 추가
  • 72. Step 9 : Publish to Feed 3: Set Up the Share View 3-4. Configure the Display Data ViewDidLoad 메소드에 추가
  • 73. Step 9 : Publish to Feed 3: Set Up the Share View 3-5. Load the Story Image ViewDidLoad ViewDidUnLoad
  • 74. Step 9 : Publish to Feed 3: Set Up the Share View 3-5. Load the Story Image NSURLConnection delegate methods - (void)connection:(NSURLConnection*)connection didReceiveData:(NSData*)data{ [self.imageData appendData:data]; } - (void)connectionDidFinishLoading:(NSURLConnection *)connection{ // Load the image self.postImageView.image = [UIImage imageWithData: [NSData dataWithData:self.imageData]]; self.imageConnection = nil; self.imageData = nil; } - (void)connection:(NSURLConnection *)connection didFailWithError:(NSError *)error{ self.imageConnection = nil; self.imageData = nil; }
  • 75. Step 9 : Publish to Feed 3: Set Up the Share View 3-6. Configure the Cancel Action - (IBAction)cancelButtonAction:(id)sender { [[self presentingViewController] dismissModalViewControllerAnimated:YES]; } 3-7. Present the Share View FBFeedViewController.m 파일에 Import & 클릭함수 구현 -(void) gofacebookpublish { FBFeedViewController *viewController = [[FBFeedViewController alloc] initWithNibName:@"FBFeedViewController" bundle:nil]; [self presentViewController:viewController animated:YES completion:nil]; }
  • 76. Step 9 : Publish to Feed 4: Publish the Story FBFeedViewController.m 파일에 Import & 클릭함수 구현 - (IBAction)shareButtonAction:(id)sender { if ([self.postMessageTextView isFirstResponder]) { [self.postMessageTextView resignFirstResponder]; } if (![self.postMessageTextView.text isEqualToString:kPlaceholderPostMessage] && ![self.postMessageTextView.text isEqualToString:@""]) { [self.postParams setObject:self.postMessageTextView.text forKey:@"message"]; } [FBRequestConnection startWithGraphPath:@"me/feed" parameters:self.postParams HTTPMethod:@"POST" completionHandler:^(FBRequestConnection *connection,id result,NSError *error) { NSString *alertText; if (error) { alertText = [NSString stringWithFormat:@"error: domain = %@, code = %d",error.domain, error.code]; } else { alertText = [NSString stringWithFormat:@"Posted action, id: %@",[result objectForKey:@"id"]]; } [[[UIAlertView alloc] initWithTitle:@"Result" message:alertText delegate:self cancelButtonTitle:@"OK!" otherButtonTitles:nil] show]; }]; }
  • 77. Step 9 : Publish to Feed 4: Publish the Story FBFeedViewController.m 파일에 UIAlertView delegate 함수 구현

Notes de l'éditeur

  1. \n
  2. \n
  3. \n
  4. \n
  5. \n
  6. \n
  7. \n
  8. \n
  9. \n
  10. \n
  11. \n
  12. \n
  13. \n
  14. \n
  15. \n
  16. \n
  17. \n
  18. \n
  19. \n
  20. \n
  21. \n
  22. \n
  23. \n
  24. \n
  25. \n
  26. \n
  27. \n
  28. \n
  29. \n
  30. \n
  31. \n
  32. \n
  33. \n
  34. \n
  35. \n
  36. \n
  37. \n
  38. \n
  39. \n
  40. \n
  41. \n
  42. \n
  43. \n
  44. \n
  45. \n
  46. \n
  47. \n
  48. \n
  49. \n
  50. \n
  51. \n
  52. \n
  53. \n
  54. \n
  55. \n
  56. \n
  57. \n
  58. \n
  59. \n
  60. \n
  61. \n
  62. \n
  63. \n
  64. \n
  65. \n
  66. \n
  67. \n
  68. \n
  69. \n
  70. \n
  71. \n
  72. \n
  73. \n
  74. \n
  75. \n
  76. \n
  77. \n