我想發佈的頁面的頁面我聯繫Facebook上的JavaScript - 崗位作爲頁
下面的代碼可能有一些不必要的位,但我試圖覆蓋所有我的基地
這裏是一個基本的HTML表,我們將撤出它的數據,並張貼到fb
<table style="width: 100%;">
<tr><td>1 col 1</td><td>1 col 2</td><td>1 col 3</td><td>1 col 4</td><td>1 col 5</td><td>1 col 6</td><td>1 col 7</td></tr>
<tr><td>2 col 1</td><td>2 col 2</td><td>2 col 3</td><td>2 col 4</td><td>2 col 5</td><td>2 col 6</td><td>2 col 7</td></tr>
<tr><td>3 col 1</td><td>3 col 2</td><td>3 col 3</td><td>3 col 4</td><td>3 col 5</td><td>3 col 6</td><td>3 col 7</td></tr>
</table>
和腳本,我試圖評論每一節用什麼應該做
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
<script>
window.fbAsyncInit = function() {
FB.init({
appId : {APP_ID_HERE}, // unique app id
version : 'v2.7',
cookie : true,
status : true
});
};
// connect to facebook
(function(d, s, id){
var js, fjs = d.getElementsByTagName(s)[0];
if (d.getElementById(id)) {return;}
js = d.createElement(s); js.id = id;
js.src = "//connect.facebook.net/en_US/sdk.js";
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));
// set up what we are actually posting to facebook
(function($)
{
$('tr').each(function()
{
var msg = $(this).find('td:nth-of-type(6)').text();
$(this).find('td:first-of-type').append('<span class="left" onclick="fbPostIt(\'' + msg + '\')">[fb]</span>');
})
})(jQuery);
// do the work
function fbPostIt(fbPost){
var pageId = '{PAGE_ID_HERE}'; // facebook page id from page info
// ensure we have permissions we need
FB.login(function(){
// used to get user accessToken
var authResp = FB.getAuthResponse();
// see what accounts user has access to
FB.api('/me/accounts', 'get', {access_token : authResp.accessToken}, function(response){
console.log(response); // this is returning an object with the accounts
FB.api('/me/permissions', 'get', {access_token : pageAccessToken}, function(resp){console.log(resp)});
/**
* permissions listed are "manage_pages", "publish_actions" and "public_profile"
* all marked as "status : granted"
*/
// find the page access token for the page we want to admin
var pageAccessToken = '';
for(i in response.data){
if(response.data[i].id == pageId) {
pageAccessToken = response.data[i].access_token;
// do the actual post now
FB.api('/' + pageId + '/feed', 'post', {
message: fbPost,
access_token : pageAccessToken
}, function(info){
console.log(info);
/**
* code : 200
* message : "(#200) The user hasn't authorized the application to perform this action"
* type : "OAuthException"
*/
});
}
}
});
}, { scope: 'manage_pages, publish_actions' });
}
</script>
我不知道如果我失蹤Facebook在我的應用程序設置的東西,或者在代碼中,我看不出有什麼毛病徹底的代碼,但希望一些新鮮的眼睛可以幫助
當我按下按鈕後的第一次,Facebook的要求提供3套權限
- 訪問配置文件
- 張貼代表我
- 管理
所有這三個我說是
不錯你投票沒有理由爲什麼?這是一個有效的問題,我展示了比其他任何人有類似問題更多的工作 – Kender