0

Actually i want to upload photo on facebook fan page so for this i wrote below code

[m_facebook setAccessToken:@"BAAGgxy3PqqcBAHqByi2JOtTs .....8SCo8MK22y0smcFnxFEt7U6zVP2U4WpLrpnDWNuwXpvSYB9Btt7ZCMljBGmfxgPKoOdmadmNitSZB47trDv9hXd4wAE3VjZBbWBGMPP1lV8H1rfTcXNRuX8ePqRhxXsAypA7uHkSVyZASp0oaVfY0sJF55O8agZDZD"];

[m_facebook requestWithGraphPath:@"437...6356137/photos"
                               andParams:fbArguments
                           andHttpMethod:@"POST"
                             andDelegate:self];

With above code i am able to post photo on my facebook fan page but the problem is i have to hard code Page_Access_Token as you can see so can any one tell me that how i can access this Page_Access_Token token dynamically using FBConnect. I have already went through this link.

Community
  • 1
  • 1
Stan Roger
  • 67
  • 12

1 Answers1

1

You have to authenticate by this line

NSArray *permissions =  [[NSArray arrayWithObjects:@"read_stream", @"offline_access", @"publish_stream", @"manage_pages", @"user_photos", @"friends_photos",nil] retain];
[facebook authorize:FB_APP_ID permissions:permissions delegate:self];

Once you get authenticated , you will get AccessToken via this delegate method

  - (void)fbDidExtendToken:(NSString*)accessToken expiresAt:(NSDate*)expiresAt
{
      //Use access token
}

 - (void)fbDidLogin {
[self.facebook1 accessToken];//you can access token once you get this call back.

}

Note: When you call extendAccessToken to extend token, the above delegate will call in that time too. fbDidLogin delegate method call when you get first time authentication. fbDidExtendToken delegate method get call when you try to extend access token. accessToken will get expired depending on expirationDate.

Mani
  • 17,549
  • 13
  • 79
  • 100