Facebook Graph API - complete server side auth and API calls
Asked Answered
B

2

6

I have an application, that runs on server. On that server is background task, that will post status update on few social networks (Facebook, Twitter, G+). It must be completely server-side.

In Twitter API I'm able to use OAuth header to authorize API request. OAuth HTTP header uses consumer key, consumer secret, access token and access token secret to create the header. With this I'm able to post/update/delete tweets with no user interaction.

How can I do this for Facebook? I found a solution to obtain a long-lived access_token (2 months), but we don't want to regenerate access_token every 60 days. We want to use it for manage our Facebook page - post status updates, but completely server-side.

Am I able to do this for Facebook? Thanks for answers. PS: I searched stackoverflow hundred-times but with no solution for my problem.

Thanks.

Boyer answered 6/10, 2014 at 7:57 Comment(0)
T
5

It is not possible for User Access Tokens (they can only be extended to 60 days and need to be refreshed by the user after that), but for posting to a Page you should use a Page Token anyway. An Extended Page Token is valid forever.

Here are some Links to help you get that Extended Page Token:

A Page Token will post "as Page" btw, but that´s probably what you want. And auto-posting on user profiles is not really allowed anyway, every message has to be 100% user generated and every posting should get authorized by the user.

Torsi answered 6/10, 2014 at 8:43 Comment(0)
N
0

Pay attention to Access Tokens Expiration & Extentions. The Page Access Token could be a good solution to only server side calls for testing and data analysis purposes.

  1. Take your User Access Token from Graph API Tool
  2. Extend your User Access Token
  3. Call https://graph.facebook.com/v2.11/me/accounts with your user access token extended

*all calls are GET and this procedure does not use APP Access Token.

Nesmith answered 13/11, 2017 at 14:12 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.