title: Posting as a Facebook Page using Swift
body: <p>I would like my app to post to my Facebook business page. I've can get it to post to my person Facebook feed, and I've also gotten it to post to my business page, posting as my personal user account. However, I'd like it to post to the main business page feed, as the business account.</p>
  
  <p>As shown here in Facebook's documentation:
  <a href="https://developers.facebook.com/docs/pages/publishing" rel="nofollow noreferrer">https://developers.facebook.com/docs/pages/publishing</a></p>
  
  <p>Here's is what I've tried. The following code posts to the page using my personal user account.</p>
  
  <p>I was trying to replace the accessToken parameter in the POST GraphRequest with the pageAccessToken... but couldn't get it to work.</p>
  
  <pre><code>var pageAccessToken : GraphResponse?
  
  func getPageAccessToken() {
  
      let connection = GraphRequestConnection()
  
      connection.add(GraphRequest(graphPath: "/\(pageID)?fields=access_token")) { httpResponse, result in
          switch result {
          case .success(let response):
              print("Graph Request Success: \(response)")
              self.pageAccessToken = response
          case .failed(let error):
              print("Graph Request Fail: \(error)")
          }
      }
      connection.start()
  }
  
  
  func requestPublishPermissions() {
  
      let loginManager = LoginManager()
  
      loginManager.logIn(publishPermissions: [ .managePages, .publishPages], viewController: self) { loginResult in
          switch loginResult {
          case .failed(let error):
              print(error)
          case .cancelled:
              print("User cancelled login.")
          case .success(let grantedPermissions, let declinedPermissions, let accessToken):
              print("grantedPermissions = \(grantedPermissions) \n" +
                  "declinedPermissions = \(declinedPermissions) \n" +
                  "accessToken = \(accessToken)")
          }
      }
  }
  
  func postMessage() {
  
      let requestPage : GraphRequest = GraphRequest(graphPath: "\(pageID)/feed", parameters: ["message" : "Hello Page!"], accessToken: AccessToken.current, httpMethod: .POST, apiVersion: .defaultVersion)
  
      requestPage.start({ (connection, result) -&gt; Void in
          print("RESULT = \(result)")
      })
  }
  </code></pre>
  
  <p>Thank you for any advice tips you can give!</p>