我正在尝试将图片和内容从网页分享到用户的FB墙,但它没有发布。图像以共享弹出方式显示,但未在用户墙中显示。 我为此目的有以下代码。 在头部我有
<meta property="og:url" content="http://objdevelopment.com/notice/ddfdf" />
<meta property="og:type" content="website" />
<meta property="og:title" content=" Notice of Passing" />
<meta property="og:description" content="Notice of Passing " />
<meta property="og:image" content="http://objdevelopment.com/notice/wp-content/uploads/65a4465e9258729f8085c4d780700dad.jpg" />
在HTML中我有
<div id="fb-root"></div>
<script type='text/javascript'>
(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 = "http://connect.facebook.net/en_US/sdk.js#version=v2.3&appId=937475996303874&status=true&cookie=true&xfbml=true";
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));</script>
<!-- Your share button code -->
<div class="fb-share-button" data-href="http://objdevelopment.com/notice/onope/ddfdf/"
data-layout="button_count">
</div>
它显示为http://www.awesomescreenshot.com/image/510674/5e1cdc7572ab3946a36a23ff2c49b014
单击“共享”按钮,将在下面的窗口中打开 https://drive.google.com/file/d/0B54OjkhFLGPXNXI2MWgya1RRWFU/view?usp=sharing
并在墙上显示如下http://www.awesomescreenshot.com/image/510678/ca4fc6be51aed2db5049b96546a6cd99
我的期望是: https://drive.google.com/file/d/0B54OjkhFLGPXdGluaF9PNzdEakk/view?usp=sharing
如需进行实时测试,请访问
答案 0 :(得分:0)
在网上找到一些资源并解决了这个问题。我使用以下代码来解决此问题
<强> HTML 强>
<a class="fb-share-button fb_share" href="#" data-href="[page_url]" data-image="[image_url]" data-title="[Post_title] " data-desc="[Post_description]" > <i class="fa fa-facebook"></i> </a>
<强>的Javascript 强>
<script>
/**FB SHARE**/
window.fbAsyncInit = function() {
FB.init({
appId: 937475996303874,
status: true,
cookie: false,
xfbml: true
});
};
(function(d, debug){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" + (debug ? "/debug" : "") + ".js";ref.parentNode.insertBefore(js, ref);}(document, /*debug*/ false));
function postToFeed(title, desc, url, image) {
var obj = {method: 'feed',link: url, picture: image,name: title,description: desc};
function callback(response) {}
FB.ui(obj, callback);
}
var fbShareBtn = document.querySelector('.fb_share');
//fbShareBtn.addEventListener('click', function(e) {
jQuery('.fb_share').click(function(e){
e.preventDefault();
//alert();
var title = fbShareBtn.getAttribute('data-title'),
desc = fbShareBtn.getAttribute('data-desc'),
url = fbShareBtn.getAttribute('href'),
image = fbShareBtn.getAttribute('data-image');
//console.log(image+ "Hello");
postToFeed(title, desc, url, image);
return false;
});
/**FB SHARE**/
</script>
在Html中,用您自己的值替换[]之间的文本。
答案 1 :(得分:-1)
我认为你必须调试你的网站网址,在这里你可以看到facebook分享的图片。 (https://developers.facebook.com/tools/debug/)。请试一试。