所以我使用这个博客共享脚本很长一段时间,现在它停止了工作。也许facebook改变了一些我不知道的东西也许你可以帮助我们,因为整整一周我都在试图找到谁可以修复这个脚本..也许你可以将它用于你自己的网站..
将此代码放在标记后的博客模板中,输入应用ID并填写其他字段但不是必需的。 所以代码:
<!-- FACEBOOK VIRAL SCRIPT BEGIN -->
<style>
#fvsbg {
position:fixed;
top:0;
left:0;
z-index: 99;
background-color: rgba(0,0,0,0);
width: 100%;
height: 100%;
}
#fvsmain {
position:fixed;
top:200px;
left:50%;
margin-left:-225px;
z-index:100;
width:450px;
color:#333;
text-align:center;
font-family:arial,sans-serif;
font-size:13px;
background:transparent;
line-height:1;
height:200px;
display:none;
}
#sharebtn {
width: 200px;
margin: 0 auto;
display: block;
position: relative;
}
#h1 {
color: #FFFFFF;
font-size: 2em;
margin: 0.67em 0;
text-shadow: 0.1em 0.1em 0.2em black
}
@media screen and (max-device-width: 480px) {
#fvsmain {
position:fixed;
top:0;
}
}
</style>
<div id="fb-root"></div>
<script type="text/javascript">
// SETTINGS (put information inside "")
// See this screenshot to understand separate parts: http://img62.imageshack.us/img62/7468/hnk2.png
var AppID = '000000'; // your Facebook App ID
var link = 'http://example.blogspot.com'; // link to your blog (must be the same as app's domain)
var title = 'bbbb'; // title of the post
var description = 'bbbb'; //description of the post
var picture = ''; //image link for post
// --------
// FACEBOOK API
window.fbAsyncInit = function() {
// init the FB JS SDK
FB.init({
appId: AppID
});
// Additional initialization code such as adding Event Listeners goes here
};
// Load the SDK asynchronously
(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";
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));
function feed(){
FB.ui(
{
method: 'feed',
name: title,
link: link,
picture: picture,
description: description
},
function(response) {
if (response.post_id) {
SetCookie("FVSC","TRUE",1);
document.getElementById("fvsbg").style.display="none";
document.getElementById("fvsmain").style.display="none";
} else {
alert('You must share this to unlock the page!');
}
}
);
}
// FB API END
function SetCookie(cookieName,cookieValue,nDays) {
var today = new Date();
var expire = new Date();
if (nDays==null || nDays==0) nDays=1;
expire.setTime(today.getTime() + 3600000*24*nDays);
document.cookie = cookieName+"="+escape(cookieValue)
+ ";expires="+expire.toGMTString();
}
function ReadCookie(cookieName) {
var theCookie=" "+document.cookie;
var ind=theCookie.indexOf(" "+cookieName+"=");
if (ind==-1) ind=theCookie.indexOf(";"+cookieName+"=");
if (ind==-1 || cookieName=="") return "";
var ind1=theCookie.indexOf(";",ind+1);
if (ind1==-1) ind1=theCookie.length;
return unescape(theCookie.substring(ind+cookieName.length+2,ind1));
}
window.onload=function() {
if(ReadCookie("FVSC") == "TRUE")
{
document.getElementById("fvsbg").style.display="none";
document.getElementById("fvsmain").style.display="none";
}
if(ReadCookie("FVSC") != "TRUE")
{
document.getElementById("fvsbg").style.backgroundColor="rgba(0,0,0,0.6)";
document.getElementById("fvsmain").style.display="block";
}
};
if(document.URL.indexOf("blogspot") >= 0)
{
if(document.URL.split('.')[1] + document.URL.split('.')[2] + document.URL.split('.')[3] != 'blogspotcom/undefined')
{
window.location = link + "/ncr";
}
}
</script>
<div id="fvsbg"></div>
<div id="fvsmain">
<h1 id="h1" class="center">Share to Unlock this page</h1>
<a href="#" onclick="feed();"><img id="sharebtn" src="http://i.imgur.com/5mSP6c1.png" /></a>
</div>
<!-- FACEBOOK VIRAL SCRIPT END -->