0

I am new in swift so please help me regarding FBSDK. Fetching FB pages of a fb account. I need it to post on fb page directly from my app.

Jason Aller
  • 3,541
  • 28
  • 38
  • 38
Vitul Goyal
  • 95
  • 1
  • 7

1 Answers1

0

Hi i found answer for this myself.. here is my answer .. hope it will help someone :

let graphRequest
 = FBSDKGraphRequest(graphPath: "/me/accounts?fields=access_token", parameters: ["access_token":FBSDKAccessToken.current().tokenString])
graphRequest.start(completionHandler: { (connection, result, error)-> Void in
            if ((error) != nil)
            {
                print("Error: \(error)")
            }
            else
            {

                let array = ((result as! NSDictionary).value(forKey: "data") as! NSArray)

                for tokens in array{
                    let tkn = ((tokens as! NSDictionary).value(forKey: "access_token")) as! String
                    let id = ((tokens as! NSDictionary).value(forKey: "id")) as! String
                    let obj = AccessToken()  //NSOBject class containing accessToken and id variables...
                    obj.access_token=tkn
                    obj.id=id
                    self.accessTokenArray.append(obj)  // global var to store AccessToken type array
                }

            }
        })
Vitul Goyal
  • 95
  • 1
  • 7