2012-05-02 30 views
1

我每天都想運行一個耙子任務,將更新發布到應用程序的Facebook頁面。該頁面在Facebook>應用程序>設置>高級(在底部)下定義。使用應用程序令牌在頁面中發佈應用程序頁面?考拉

我想獲取應用訪問令牌,然後作爲頁面發佈到頁面。這是什麼樣的,我想,但它不工作:

@oauth = Koala::Facebook::OAuth.new(CONFIG['appid'], CONFIG['appsecret']) 
@token = @oauth.get_app_access_token 
@page_graph = Koala::Facebook::API.new(@token) 
@page_graph.put_connections('NAME_OF_PAGE','feed', :message => 'This is posted as the page') 

的錯誤,我得到:

OAuthException: (#200) The user hasn't authorized the application to perform this action 

我不知道是否有一個地方(我試過路過如在@ oauth.get_app_access_token一個選項):

@ oauth.get_app_access_token(:權限=> 「manage_pages」)

還是什麼都沒有。有任何想法嗎?


[更新]

所以我改成:

@oauth = Koala::Facebook::OAuth.new(CONFIG['appid'], CONFIG['appsecret']) 
@token = @oauth.get_app_access_token 
@page_graph = Koala::Facebook::API.new(@token) 
@postid = @page_graph.put_connections(CONFIG['appid'],'feed', :message => 'This is posted as the page') 

後來,當我輸出@postid,我得到一個有效的身份證件。我把這個ID放在:https://graph.facebook.com/POSTID,我得到了一個有效的回覆。

這是超級混亂。爲什麼它沒有出現在頁面上?

+0

@ page_graph.put_connections(CONFIG [「APPID」],「喂」,:消息=>「這是張貼在網頁」) 沒有給出錯誤,但它仍然沒有發佈到飼料 – Marc

回答

1

我遇到同樣的問題。到目前爲止,我只找到了OAuth的這種方法,才能獲得許可,出版:

@ oauth.url_for_oauth_code(:權限=>「publish_stream」)

,但我一直有錯誤,我可以」將此方法應用於字符串。我認爲它失敗了,它不會返回oAuth結構,而是返回一個字符串。

+0

只返回一個網址 – Marc

相關問題