我正在尝试在我的 Facebook 应用程序中执行“推荐”操作。我的 index.html 页面中的代码是
<head prefix="og: http://ogp.me/ns# fb: http://ogp.me/ns/fb# aspxtesting: http://ogp.me/ns/fb/aspxtesting#">
<meta property="fb:app_id" content="539397469421547" />
<meta property="og:type" content="item" />
<meta property="og:url" content="http://localhost:4816/SageFrame/recommend.html" />
<meta property="og:title" content="Sample Item" />
<meta property="og:image" content="https://s-static.ak.fbcdn.net/images/devsite/attachment_blank.png" />
</head>
<div id="fb-root">
</div>
<div>
<input type="button" runat="server" class="recommend" id="btnrecommend" value="recommend" />
</div>
<script type="text/javascript">
window.fbAsyncInit = function() {
FB.init({
appId: '539397469421547', // App ID
status: true, // check login status
cookie: true, // enable cookies to allow the server to access the session
xfbml: true // parse XFBML
});
};
// Load the SDK Asynchronously
(function(d) {
var js, id = 'facebook-jssdk', ref = d.getElementsByTagName('script')[0];
if (d.getElementById(id)) { return; }
js = d.createElement('script'); js.id = id; js.async = true;
js.src = "//connect.facebook.net/en_US/all.js";
ref.parentNode.insertBefore(js, ref);
$('.recommend').click(function(){
FB.api('https://graph.facebook.com/me/aspxtesting:recommend?Item=http://localhost:4816/SageFrame/recommend.html&access_token=' + access_token + '', 'post', function(response) {
if (!response || response.error) {
debugger;
}
});
} (document));
接下来我有recommend.html页面
<html xmlns="http://www.w3.org/1999/xhtml" dir="ltr" lang="en-US" xmlns:fb="https://www.facebook.com/2008/fbml">
<head prefix="og: http://ogp.me/ns# fb: http://ogp.me/ns/fb# aspxtesting: http://ogp.me/ns/fb/aspxtesting#">
<meta property="fb:app_id" content="539397469421547" />
<meta property="og:type" content="item" />
<meta property="og:url" content="http://localhost:4816/SageFrame/recommend.html" />
<meta property="og:title" content="Sample Item" />
<meta property="og:image" content="https://s-static.ak.fbcdn.net/images/devsite/attachment_blank.png" />
</head>
<body></body>
</html>
但我收到错误您尝试发布的操作无效,因为它没有指定任何引用对象。必须至少指定以下属性之一:item。