2012-12-09 25 views
0

有沒有一種方法,使腳It按鈕的工作與OGPin It Button,它可以與OG一起使用,就像Facebook或G +一樣嗎?

<a href="http://pinterest.com/pin/create/button/?url=["pull from OG"]&media=["Pull from OG"]&description=["Pull from OG"]" class="pin-it-button" count-layout="vertical"><img border="0" src="//assets.pinterest.com/images/PinExt.png" title="Pin It" /></a> 
<script type="text/javascript"> 
(function (w, d, load) { 
var script, 
first = d.getElementsByTagName('SCRIPT')[0], 
n = load.length, 
i = 0, 
go = function() { 
    for (i = 0; i < n; i = i + 1) { 
    script = d.createElement('SCRIPT'); 
    script.type = 'text/javascript'; 
    script.async = true; 
    script.src = load[i]; 
    first.parentNode.insertBefore(script, first); 
    } 
} 
if (w.attachEvent) { 
    w.attachEvent('onload', go); 
} else { 
    w.addEventListener('load', go, false); 
} 
}(window, document, 
['//assets.pinterest.com/js/pinit.js'] 
));  
</script> 

只是想知道這是有人已經想通了,還是不是?如果這可以這樣工作,會很好,會讓生活變得簡單。

在此先感謝您提供的任何幫助!

回答

0

下面是我爲使它工作所做的工作,但不確定這是否是最好的方式,因爲它需要使用php echo來回顯開放圖形元內容的內容。

<meta property="og:title" content="Family Budget Spreadsheet for Excel"> 
<meta property="og:type" content="product"> 
<meta property="og:url" content="<?php $og_url = $_SERVER['HTTP_HOST'].$_SERVER['SCRIPT_NAME']; echo $og_url ?>"> 
<meta property="og:image" content="<?php $og_image = 'http://www.mysite.com/images/imageIneed.jpg' ; echo $og_image ?>"> 
<meta property="og:site_name" content="My Sites Name"> 
<meta property="og:description" content="<?php $og_description = 'My page description'; echo $og_description ?>"> 

然後加入從Pinterest的

<a href="http://pinterest.com/pin/create/button/?url=<?php echo $og_url ?>&media=<?php echo $og_image ?>&description=<?php echo $og_description ?>" class="pin-it-button" count-layout="vertical"><img border="0" src="//assets.pinterest.com/images/PinExt.png" title="Pin It" /></a> 
<script type="text/javascript"> 
(function (w, d, load) { 
var script, 
first = d.getElementsByTagName('SCRIPT')[0], 
n = load.length, 
i = 0, 
go = function() { 
    for (i = 0; i < n; i = i + 1) { 
    script = d.createElement('SCRIPT'); 
    script.type = 'text/javascript'; 
    script.async = true; 
    script.src = load[i]; 
    first.parentNode.insertBefore(script, first); 
    } 
} 
if (w.attachEvent) { 
    w.attachEvent('onload', go); 
} else { 
    w.addEventListener('load', go, false); 
} 
}(window, document, 
['//assets.pinterest.com/js/pinit.js'] 
));  
</script> 

它工作得很好考慮下面的代碼,但我相信有好多這樣的方式,所以如果你有一個,請在這裏分享。

相關問題