2012-11-07 82 views
0

我在我的javascript代碼中做了很多東西,用於在頁面上張貼feed作爲m`,但是我怎麼才能通過一次點擊就可以通過javascript獲得權限。作爲管理員使用javascript api的Facebook頁面發佈

這是我的代碼。上面的腳本的

<body> 
<div id='fb-root'></div> 
<script src='http://connect.facebook.net/en_US/all.js'></script> 
<p> 
    <a href="javascript:;" onclick='postToFeed(); return false;'>Post to Group</a> 
</p> 
<p id='msg'></p> 

<script> 
    FB.init({appId: "apid", status: true, cookie: true}); 
    function postToFeed() { 
    FB.api('/page_id/feed', 'post', 
      { 
       message  : "It's awesome ...", 
       link  : 'http://csslight.com', 
       picture  : 'http://csslight.com/application/upload/WebsitePhoto/567-grafmiville.png', 
       name  : 'Featured of the Day', 
       from: 'pageid', 
       description : 'CSS Light is a showcase for web design encouragement, submitted by web designers of all over the world. We simply accept the websites with high quality and professional touch.' 
     }, 
     function(response) { 
      alert(JSON.stringify(response)); 
     }); 
    } 
    </script> 
    </body> 

輸出是

enter image description here

但我wan't張貼作爲BeCrazzy.com不Rajnish ..!

簡單地說,我想以管理員的身份在頁面上張貼feed。請幫幫我。 :)

+0

可能重複的[如何發佈到粉絲專頁,而不是用戶](http://facebook.stackoverflow.com/questions/8034753/how-to-post-to-facebook-fanpage-as-fanpage-非用戶) – ifaour

+0

我想我上面的答案仍然有效。 – ifaour

+0

是的,你是對的,但我有點混亂.. 如何獲得訪問令牌使用JavaScript API ...抱歉,我不能得到任何解決方案。 – Rajnish

回答

2

這裏有一個教程,顯示你到底如何做到這一點:

https://developers.facebook.com/docs/howtos/login/login-as-page/

您將無法使用Facebook的Javascript SDK使與頁面訪問簽署的API調用令牌,你需要使用像jQuery.ajax()這樣做。

+1

你可以給我現場演示嗎?或代碼?如果你可以的話。 – Rajnish

+1

指南中有示例代碼,請至少嘗試遵循它。 –

+0

這篇文章幫助我訪問令牌:http://stackoverflow.com/questions/12168452/long-lasting-fb-access-token-for-server-to-pull-fb-page-info/21927690#21927690 – Mark

相關問題