2014-09-07 3 views
0

사용 권한 및 부여 방법에 대해 중요한 내용을 이해하지 못합니다. Facebook 페이지를 만들었고 앱을 만들었습니다. 앱이 페이지에 게시 할 수있게하고 싶습니다.페이스 북 페이지에 올릴 수있는 권한을 페이스 북에 부여하려면 어떻게해야합니까?

아래 코드는 제 코드입니다. 나는 BTW (https://github.com/nov/fb_graph)

app = FbGraph::Application.new('531508086900000000', :secret => 'd705fda7275125913a10000000000') 
token = app.get_access_token 
page = FbGraph::Page.new('000000000000000') 
note = page.note!(:access_token => token, :subject => 'testing', :message => 'Hey, testing you!') 

을 fb_graph 루비 보석을 사용하고 있습니다 그리고 이것은 오류입니다 :

FbGraph::Unauthorized: OAuthException :: (#200) Requires extended permission: publish_actions 

내가 응용 프로그램 및 페이지 설정 모두에서 생각할 수있는 모든 곳에서 봤는데 그러나 이것을하는 방법을 이해할 수는 없습니다. 도움말 감사!

답변

0

나는 그가 여기 IRC 나에게 있었다/도움말 초 동안 phwd의 대답을 투표했다. 그러나 이것이 왜 그렇게 어려운지 이해하는 데는 여전히 충분한 정보가 아닙니다. 나는 이것이 어떻게 작동하는지에 대한 현재의 일하는 이해를 게시하기로 결정했다. 이것들은 단지 내 노트입니다. 그래서 나는 이해할 수없는 것을 미리 유감스럽게 생각합니다.

So, getting the right access tokens is f***ing hard, and here's my current understanding: 

In order to get a token that last forever so that my app can post to a page I have to do this: 

1. Create a short-lived user access token with the right scope for the app (manage_pages, publish_actions) using the explorer 
    - page access tokens can be obtained via /me/accounts from the explorer page 
    - if the user access token that is "live" during the /me/accounts request is short lived then this page access token will be too 
    - if it is an extended long-lived token the page access token will have no expiry according to https://developers.facebook.com/docs/facebook-login/access-tokens 

2. Extend short-lived user access token to a long-lived one via a graph api call, also using exploer (see below) 
3. Execute the /me/accounts call to get a page token that doesn't expire 

How to get a long lived user access token 
    oauth/access_token?grant_type=fb_exchange_token&client_id=531------------&client_secret=e005f031ba3d98------------------&fb_exchange_token=CAAHjZA163IbMBAMKSeFTmeV9------------------------------------------------------------------------------------------------------------------------------------------------fonA4P4bPhhdveMLvZBKldEGCB7EvF301wQv1YPrudy5kvI 
    where 

    client_id   = App Id 
    &client_secret  = App Secret 
    &fb_exchange_token = short lived user access token via explorer with proper scope 

This gives you the following long lived access token 
access_token=CAAHjZA163Ib---------------------------------------------------------------------------------------------------------------------------------------------------------------------ehS8g2ZBYU8uZBPmdMay3AAj5tXgAZDZD&expires=5179843 

This is an extended user access_token 
This token can be used to post to the page it was genrated for. 
It can also be used to get a no-expiry page access token when used to issue /me/accounts 
관련 문제