I’m developing a ruby script that push every new content on my Facebook Page as a post.
I know about that the access token will expire in two hours, so how I could do that?
Now this piece of code works because I set “user_access_token” manually (But after 2 hours it expire). It’s my company facebook page linked to my facebook app.
Should I click every two hours on “Facebook connect” and grant a new access token??
@user_graph = Koala::Facebook::API.new(user_access_token)
pages = @user_graph.get_connections('me', 'accounts')
# get access token for first page
first_page_token = pages.first['access_token']
# or: retrieve access_token for a given page_id
page_token = @user_graph.get_page_access_token(page_id)
@page_graph = Koala::Facebook::API.new(page_token)
@page_graph.put_wall_post('post on page wall') # post as page, requires publish_stream permission
I have got “Page Access Token” from here

but in one hour it will expire

[RESOLVED]
To get an extended Page Access Token, exchange the User Access Token for a long-lived one and then request the Page token. This “extended” token for Pages will actually not have any expiry time.
https://developers.facebook.com/docs/howtos/login/extending-tokens/#step1
I have resolved executing a curl request, and saving “Page access token” in my code manually
Get a page access token – those don’t expire per default; and make sure to do so with a long-time user access token