我尝试在drupal中实现facebook分享和喜欢按钮进入我的网站..但它没有从facebook获取按钮..只是显示我在模块中放置的代码..提前感谢..
facebook.module
<?php
function facebook_node_view($node, $view_mode, $langcode)
{
$node->content['facebook'] = array(
'#markup' => theme('facebook_add_like_button'),
);
}
function facebook_theme()
{
return array(
'facebook_add_like_button' => array('variables' => NULL),
);
}
function theme_facebook_add_like_button()
{
$output ='<div id="fb-root"></div><script src = "http://connect.facebook.net/en_US/all.js#xfbml=1&appId=657379467662635"></script><fb:like href="https://developers.facebook.com/docs/plugins/" layout="standard" action="like" show_faces="true" share="true"></fb:like>';
return $output;
}
This is the code i get from facebook developer
<div id="fb-root"></div>
<script>(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#xfbml=1&appId=657379467662635";
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));</script>
<fb:like href="https://developers.facebook.com/docs/plugins/" layout="standard" action="like" show_faces="true" share="true"></fb:like>
答案 0 :(得分:1)
这是因为您在主题函数中输出html实体(例如&#34;&amp; lt;&#34;)而不是实际的HTML代码。 替换&#34; $ output&#34;中的所有内容变量与您从Facebook开发人员那里获得的代码如下:
$output ='<div id ... share="true"></fb:like>';
而不是
$output ='<div id= ... share="true"></fb:like>';