我正在尝试使用localhost xampp.My项目在Facebook上分享动态内容,而不是在任何域上传。问题是,当我点击Facebook链接然后打开新对话框但路径使用搜索栏无法正常工作{ {3}} .. 但是当我在单独的标签中使用相同的路径https://www.facebook.com/dialog/feed?app_id=141722133242641&link=http://localhost/JustClick/Professional/show_professional_detail/13时,它会显示我的网站数据。当我同时使用此网址http://localhost/JustClick/Professional/show_professional_detail/13时,它会显示&#34 ;抱歉,出了一些问题。 "这个错误。请帮我解决这个问题。 localhost是我的baseurl 专业是我的控制者 show_professional_detail是控制器的方法 13是专业人士的身份
Here is my code of show_professional_detail method:
<meta property="og:url" content="http://localhost/JustClick/Professional/show_professional_detail?id=<?php echo $row->pro_id; ?>" />
<meta property="og:type" content="website" />
<meta property="og:title" content="<?php echo $row->pro_business_name; ?>" />
<meta property="og:description" content="<?php echo $row->pro_email; ?>" />
<meta property="og:image" content="http://localhost/JustClick/Professional/show_professional_detail<?php echo $row->professional_image; ?>" />
<li><p class="icon show_detail_icon_fb"><a data-toggle="tooltip" data-placement="right" title="Facebook" href="javascript:void(0);" onclick="fb_share('<?php echo base_url('Professional/show_professional_detail/'.$row->pro_id) ?>','<?php echo $row->pro_business_name?>')" class="fbBtm">
<img src="<?php echo base_url('assets/graphics/facebook-icon.png') ?>" width="40" height="40" alt="Facebook" />
</a></p></li>
Here is my javascript code:
<div id="fb-root"></div>
<script type='text/javascript'>`enter code here`
(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_GB/sdk.js#xfbml=1&version=v2.3&appId=141722133242641";
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));
function fb_share(dynamic_link,dynamic_title) {
var app_id = '141722133242641';
var pageURL="https://www.facebook.com/dialog/feed?app_id=" + app_id + "&link=" + dynamic_link;
var w = 600;
var h = 400;
var left = (screen.width / 2) - (w / 2);
var top = (screen.height / 2) - (h / 2);
window.open(pageURL, dynamic_title, 'toolbar=no, location=no, directories=no, status=no, menubar=yes, scrollbars=no, resizable=no, copyhistory=no, width=' + 800 + ', height=' + 650 + ', top=' + top + ', left=' + left)
return false;
}
</script>
Please help me.
答案 0 :(得分:1)
Follow the bellow steps:
Step #1: Use the bellow script at the bottom of page before </body> tag.
<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="//connect.facebook.net/en_GB/sdk.jsBxfbml=1&version=v2.3&appId=facebook_app_id";
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));
function fb_share(dynamic_link,dynamic_title){
var app_id='facebook_app_id';
var pageURL="https://www.facebook.com/dialog/feed?app_id="+ app_id +
"&link" + dynamic_link;
var w=600;
var h=400;
var left = (screen.width / 2) - (w / 2);
var top = (screen.height / 2) - (h / 2);
window.open(pageURL, dynamic_title,
'toolbar=no,location=no,directories=no,status=no,menubar=yes,scrollbars=no,
resizable=no,copyhistory=no, width=' + 800 + ',height=' + 650 + ',top=' +
top + ',left=' + left)
return false;
}
</script>
Step #2: Add this meta tags in under <head> tag and get content from Database.
<meta property="og:url" content="dynamic_page_full_link">
<!-- for inastance http://mywebname.com/View_news/<?php echo $id; ?> -->
<meta property="og:type" content="website">
<meta property="og:title" content="<?php echo $news_title; ?>">
<meta property="og:description" content="<?php echo $news_message; ?>">
<meta property="og:image" content="<?php echo base_url(); ?>admin/files<?php echo $news_image; ?>">
Step #3: Your own link for facebook share button.
<li>
<p class="icon show_detail_icon_fb">
<a data-toggle="tooltip" data-placement="right" title="Facebook" href="javascript:void(0);" onclick="fb_share('<?php echo base_url('Professional/show_professional_detail/'.$row->pro_id) ?>','<?php echo $row->pro_business_name?>')" class="fbBtm">
<img src="<?php echo base_url('assets/graphics/facebook-icon.png') ?>" width="40" height="40" alt="Facebook" />
</a></p></li>
That's it.