[英]facebook share error: “method” is a required parameter for FB.ui()
标题说明了一切。 我总是收到此错误:“方法”是FB.ui()的必需参数。 但是方法设置为“提要”
是因为我当前在计算机上本地工作,而不是在真正的服务器上工作? 应用也已在Facebook中注册。
任何想法?
<span id='share'>SHARE</span>
<div id="fb-root"></div>
<script>
window.fbAsyncInit = function() {
FB.init({appId: '2907534********', status: true, cookie: true, xfbml: true});
};
(function() {
var e = document.createElement('script'); e.async = true;
e.src = document.location.protocol +
'//connect.facebook.net/en_US/all.js';
document.getElementById('fb-root').appendChild(e);
}());
</script>
<script type="text/javascript">
$(document).ready(function(){
$('#share').click(function(e){
e.preventDefault();
FB.ui({
method: 'feed',
name: 'This is the content of the "name" field.',
link: ' http://www.hyperarts.com/',
picture: 'http://www.hyperarts.com/external-xfbml/share-image.gif',
caption: 'This is the content of the "caption" field.',
description: 'This is the content of the "description" field, below the caption.',
message: ''
});
});
});
</script>
代码的$('#share').click(function(e){
部分$('#share').click(function(e){
应该进入window.fbAsynchInit调用,以确保在将click事件分配给使用FB的对象之前加载了框架。
我用自己的应用程序ID测试了相同的代码,对我来说很好用。 唯一的区别是,我将名称,标题和描述更改为“ This”,并在最后修复了语法问题。
您确定这部分代码是错误的根源吗?
例如,如果您插入画布( https://www.example.com/test.php ),并且必须将此代码放在test.php
希望您的问题能很快得到解决!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.