Javascript 如何在Facebook上共享一个简单的图像(通过回调)? 目标
通过Facebook的墙分享一个简单的图像 问题 或者,如果某一天图像脱机: API错误代码:191 API错误描述:指定的URL不属于应用程序 错误消息:应用程序不拥有重定向uriJavascript 如何在Facebook上共享一个简单的图像(通过回调)? 目标,javascript,facebook,Javascript,Facebook,通过Facebook的墙分享一个简单的图像 问题 或者,如果某一天图像脱机: API错误代码:191 API错误描述:指定的URL不属于应用程序 错误消息:应用程序不拥有重定向uri 我的问题是:我做错了什么? 情景 首先,我加载Facebook的JavaScript SDK: <script type="text/javascript"> window.fbAsyncInit = function() { FB.init({
我的问题是:我做错了什么? 情景 首先,我加载Facebook的JavaScript SDK:
<script type="text/javascript">
window.fbAsyncInit = function() {
FB.init({
appId: 'xxx',
channelUrl: '//localhost/channel.html',
status: true,
xfbml: true
});
};
(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>
最后,这是我的应用程序:
尝试以下方法
<script type="text/javascript">
function publishOnFacebook() {
FB.ui(
{
method: 'feed',
name: 'Facebook Dialogs',
link: 'http://localhost/',
picture: 'http://fbrell.com/f8.jpg',
caption: 'Reference Documentation',
description: 'Dialogs provide a simple, consistent interface for applications to interface with users.'
},
function(response) {
if (response && response.post_id) {
alert('Post was published.');
} else {
alert('Post was not published.');
}
}
);
}
</script>
<a href="#" onClick="publishOnFacebook()">
<i class="icons icon-facebook-big"></i></a>
函数publishOnFacebook(){
FB.ui(
{
方法:“提要”,
名称:“Facebook对话”,
链接:'http://localhost/',
图片:'http://fbrell.com/f8.jpg',
标题:“参考文档”,
描述:“对话框为应用程序与用户交互提供了一个简单、一致的界面。”
},
功能(响应){
if(应答和应答后id){
警报(“发布帖子”);
}否则{
警报(“未发布帖子”);
}
}
);
}
Changeredirect\u uri
到前面的Facebook(任何应用程序都可以使用回退)尝试共享的链接链接:'https://developers.facebook.com/docs/dialogs/“
不是您在设置中指定的应用程序域,尝试将其更改为http://localhost/myHTMl.html
按照您的建议,在哪里更改重定向uri
,@AdamZapp?redirect_uri
isSite Url
在新的fb API中不推荐应用程序内设置“picture”参数。
function publishOnFacebook() {
FB.ui(
{
method: 'feed',
name: 'Facebook Dialogs',
link: 'https://developers.facebook.com/docs/dialogs/',
picture: 'http://fbrell.com/f8.jpg',
caption: 'Reference Documentation',
description: 'Dialogs provide a simple,
consistent interface for applications to
interface with users.'
},
function(response) {
if (response && response.post_id) {
alert('Post was published.');
} else {
alert('Post was not published.');
}
}
);
}
<script type="text/javascript">
function publishOnFacebook() {
FB.ui(
{
method: 'feed',
name: 'Facebook Dialogs',
link: 'http://localhost/',
picture: 'http://fbrell.com/f8.jpg',
caption: 'Reference Documentation',
description: 'Dialogs provide a simple, consistent interface for applications to interface with users.'
},
function(response) {
if (response && response.post_id) {
alert('Post was published.');
} else {
alert('Post was not published.');
}
}
);
}
</script>
<a href="#" onClick="publishOnFacebook()">
<i class="icons icon-facebook-big"></i></a>