gpt4 book ai didi

facebook - 使用 js sdk 将提要发布到页面墙

转载 作者:行者123 更新时间:2023-12-02 04:47:59 25 4
gpt4 key购买 nike

我正在尝试通过 js sdk 将帖子发送到我是管理员的页面的墙上。我已经做到了,我可以为自己(我的个人用户)做,但我无法让它作为“页面”工作。

<div id="fb-root"></div>
<script type="text/javascript">
function SendToFacebook()
{
window.fbAsyncInit = function () {
// init the FB JS SDK
FB.init({
appId: '**CORRECT ID**', // App ID from the app dashboard
channelUrl: '**MYPAGE**/channel.html', // Channel file for x-domain comms
status: false, // Check Facebook Login status
xfbml: true // Look for social plugins on the page
});

FB.ui(
{
method: 'feed',
name: 'MyFeed',
link: '',
// picture: '',
caption: 'My caption',
description: 'test',
message: 'MESSAGE?',
},
function (response) {
if (response && response.post_id) {
alert('Delat på facebook.');
} else {
alert('Inte delat på facebook.');
}
}
);
// Additional initialization code such as adding Event Listeners goes here
};

// Load the SDK asynchronously
(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/all.js";
fjs.parentNode.insertBefore(js, fjs);
} (document, 'script', 'facebook-jssdk'));
}
</script>

这会发布到我自己的用户页面,我尝试了“to”参数,但它会将帖子从我的个人用户发送到该页面。有什么办法可以通过登录功能做到这一点?请记住,我对此还很陌生,因此欢迎演示和示例。

最佳答案

经过一天的辛苦工作,我让它开始工作,如果有人感兴趣,请看我是怎么做的。

<script type="text/javascript">

function SendToFacebook()
{
window.fbAsyncInit = function () {
// init the FB JS SDK
FB.init({
appId: '***', // App ID from the app dashboard
channelUrl: '***', // Channel file for x-domain comms
status: false, // Check Facebook Login status
xfbml: true // Look for social plugins on the page
});


FB.login(function (response) {
FB.api('/me/accounts', function (apiresponse) {

var data = {
message: "mymessage",
display: 'iframe',
caption: "caption",
name: "name",
description: "description",
to: **wallid**,
from: **wallid**
};

FB.api('/**wallid**/feed', 'post', data, function () {
console.log(arguments);
});


});

}, { scope: 'manage_pages' });

};
// Load the SDK asynchronously
(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/all.js";
fjs.parentNode.insertBefore(js, fjs);
} (document, 'script', 'facebook-jssdk'));
}
</script>

关于facebook - 使用 js sdk 将提要发布到页面墙,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19427890/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com