关联:
1. Facebook
Text link:
<script>function fbs_click() {u=location.href;t=document.title;window.open('http://www.facebook.com/sharer.php?u='+encodeURIComponent(u)+'&t='+encodeURIComponent(t),'sharer','toolbar=0,status=0,width=626,height=436');return false;}</script><a rel="nofollow" href="http://www.facebook.com/share.php?u=<;url>" onclick="return fbs_click()" target="_blank">Share on Facebook</a>
Small icon and text:
<script>function fbs_click() {u=location.href;t=document.title;window.open('http://www.facebook.com/sharer.php?u='+encodeURIComponent(u)+'&t='+encodeURIComponent(t),'sharer','toolbar=0,status=0,width=626,height=436');return false;}</script><style> html .fb_share_link { padding:2px 0 0 20px; height:16px; background:url(http://static.ak.facebook.com/images/share/facebook_share_icon.gif?6:26981) no-repeat top left; }</style><a rel="nofollow" href="http://www.facebook.com/share.php?u=<;url>" onclick="return fbs_click()" target="_blank" class="fb_share_link">Share on Facebook</a>
Icon only:
<script>function fbs_click() {u=location.href;t=document.title;window.open('http://www.facebook.com/sharer.php?u='+encodeURIComponent(u)+'&t='+encodeURIComponent(t),'sharer','toolbar=0,status=0,width=626,height=436');return false;}</script><style> html .fb_share_button { display: -moz-inline-block; display:inline-block; padding:1px 20px 0 5px; height:15px; border:1px solid #d8dfea; background:url(http://static.ak.facebook.com/images/share/facebook_share_icon.gif?6:26981) no-repeat top right; } html .fb_share_button:hover { color:#fff; border-color:#295582; background:#3b5998 url(http://static.ak.facebook.com/images/share/facebook_share_icon.gif?6:26981) no-repeat top right; text-decoration:none; } </style> <a rel="nofollow" href="http://www.facebook.com/share.php?u=<;url>" class="fb_share_button" onclick="return fbs_click()" target="_blank" style="text-decoration:none;">Share</a>
custom:
<script src="http://connect.facebook.net/en_US/all.js#xfbml=1"></script><fb:like href="" layout="button_count" show_faces="true" width="450" action="recommend" font=""></fb:like>
Options:
layout: "standard", "button_count" 和 "box_count";
show_faces: 'true' 和 'false'
action: 'like' 和 'Recommend'
Sources:
http://www.facebook.com/share_partners.php
http://developers.facebook.com/docs/guides/web/
custom your facebook button
http://www.buttonshut.com/facebook-badge.html
登录并获取首页:
<?php echo 'loading <br/>'; $login_email = '[email protected]'; $login_pass = 'my_sexy_password'; $fp = fopen("fb_cookies.txt", w); fclose($fp); echo 'still loading <br/>'; if (fb_login($login_email,$login_pass)){ $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, 'https://login.facebook.com/login.php?login_attempt=1'); curl_setopt($ch, CURLOPT_POSTFIELDS,'charset_test=%E2%82%AC%2C%C2%B4%2C%E2%82%AC%2C%C2%B4%2C%E6%B0%B4%2C%D0%94%2C%D0%84&locale=en_US&email='.urlencode($login_email).'&pass='.urlencode($login_pass).'&pass_placeholder=&charset_test=%E2%82%AC%2C%C2%B4%2C%E2%82%AC%2C%C2%B4%2C%E6%B0%B4%2C%D0%94%2C%D0%84'); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_HEADER, 0); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($ch, CURLOPT_COOKIEJAR, str_replace('\\','/',dirname(__FILE__)).'/fb_cookies.txt'); curl_setopt($ch, CURLOPT_COOKIEFILE, str_replace('\\','/',dirname(__FILE__)).'/fb_cookies.txt'); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.9.0.6) Gecko/2009011913 Firefox/3.0.6 (.NET CLR 3.5.30729)"); $html = curl_exec($ch); curl_close($ch); echo $html; } function fb_login($login_email, $login_pass){ $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, 'https://login.facebook.com/login.php?login_attempt=1'); curl_setopt($ch, CURLOPT_POSTFIELDS,'charset_test=%E2%82%AC%2C%C2%B4%2C%E2%82%AC%2C%C2%B4%2C%E6%B0%B4%2C%D0%94%2C%D0%84&locale=en_US&email='.urlencode($login_email).'&pass='.urlencode($login_pass).'&pass_placeholder=&charset_test=%E2%82%AC%2C%C2%B4%2C%E2%82%AC%2C%C2%B4%2C%E6%B0%B4%2C%D0%94%2C%D0%84'); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_HEADER, 0); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($ch, CURLOPT_COOKIEJAR, str_replace('\\','/',dirname(__FILE__)).'/fb_cookies.txt'); curl_setopt($ch, CURLOPT_COOKIEFILE, str_replace('\\','/',dirname(__FILE__)).'/fb_cookies.txt'); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.9.0.6) Gecko/2009011913 Firefox/3.0.6 (.NET CLR 3.5.30729)"); $html = curl_exec($ch); $err = 0; $err = curl_errno($ch); curl_close($ch); if ($err != 0){ echo 'error='.$err."\n"; return(false); } else { echo 'fetching..'; return(true); } } ?>
2. Twitter
<a href="http://twitter.com/share" class="twitter-share-button" data-count="horizontal" data-via="IBTimes" data-related="IBTimes">Tweet</a><script type="text/javascript" src="http://platform.twitter.com/widgets.js"></script>
Sources:
http://tweetmeme.com/about/retweet_button
http://twitter.com/about/resources/tweetbutton
http://www.twitterbuttons.com/
3. Stumbleupon
<script src="http://www.stumbleupon.com/hostedbadge.php?s=1"></script>
Sources:
http://www.stumbleupon.com/badges/
4. Google +1
<html> <head> <title>+1 demo: Basic page</title> <script type="text/javascript" src="https://apis.google.com/js/plusone.js"></script> </head> <body> <g:plusone></g:plusone> </body> </html>
更多查看:
http://www.google.com/webmasters/+1/button/
http://code.google.com/apis/+1button/#jsapi
5. Linkedin
<html> <head> <title>Basic page</title> </script> </head> <body> <script src="http://platform.linkedin.com/in.js" type="text/javascript"></script> <script type="IN/Share" data-url="www.ibtimes.com" data-counter="right"></script> </body> </html>
更多查看:
http://developer.linkedin.com/docs/DOC-1283
http://developer.linkedin.com/index.jspa
6. Disqus
<div id="disqus_thread"></div> <script type="text/javascript"> /* * * CONFIGURATION VARIABLES: EDIT BEFORE PASTING INTO YOUR WEBPAGE * * */ var disqus_shortname = 'example'; // required: replace example with your forum shortname (you need to register for free) // The following are highly recommended additional parameters. Remove the slashes in front to use. // var disqus_developer = 1; // var disqus_identifier = 'unique_dynamic_id_1234'; // var disqus_url = 'http://example.com/permalink-to-page.html'; // var disqus_config = function () { this.language = "it"; }; // this will set language to italy for the request, and default is en /* * * DON'T EDIT BELOW THIS LINE * * */ (function() { var dsq = document.createElement('script'); dsq.type = 'text/javascript'; dsq.async = true; dsq.src = 'http://' + disqus_shortname + '.disqus.com/embed.js'; (document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq); })(); </script> <noscript>Please enable JavaScript to view the <a href="http://disqus.com/?ref_noscript">comments powered by Disqus.</a></noscript> <a href="http://disqus.com" class="dsq-brlink">blog comments powered by <span class="logo-disqus">Disqus</span></a>
disqus_shortname tells Disqus which website account (called a forum on Disqus) this system belongs to.
disqus_identifier tells Disqus how to uniquely identify the current page.
disqus_url tells Disqus the location of the page for permalinking purposes.
如何出现类似 “We were unable to load Disqus. For more information please see our documentation on identifier and urls.” 的提示错误,可以在JavaScript中加入: var disqus_developer = 1;
更多查看:
http://docs.disqus.com/developers/universal/
7. gigya
<html> <head> <SCRIPT type="text/javascript" lang="javascript" src="http://cdn.gigya.com/JS/socialize.js?apikey=2_Y82PzwJ_chSFImHXaIDJClnLyJzmk-VFOavSsaNTzl6m901s_NNxRAS0xJ3bd3_N"> </SCRIPT> <script> var conf = { APIKey: '2_Y82PzwJ_chSFImHXaIDJClnLyJzmk-VFOavSsaNTzl6m901s_NNxRAS0xJ3bd3_N' }; // This method is activated when page is loaded function onLoad() { // register for login event gigya.services.socialize.addEventHandlers(conf, { context: { str: 'congrats on your' } , onLogin: onLoginHandler , onLogout: onLogoutHandler }); } // onLogin Event handler function onLoginHandler(eventObj) { alert(eventObj.context.str + ' ' + eventObj.eventName + ' to ' + eventObj.provider + '!\n' + eventObj.provider + ' user ID: ' + eventObj.user.identities[eventObj.provider].providerUID); // verify the signature ... verifyTheSignature(eventObj.UID, eventObj.timestamp, eventObj.signature); // Check whether the user is new by searching if eventObj.UID exists in your database var newUser = true; // lets assume the user is new if (newUser) { // 1. Register user // 2. Store new user in DB // 3. link site account to social network identity // 3.1 first construct the linkAccounts parameters var dateStr = Math.round(new Date().getTime()/1000.0); // Current time in Unix format //(i.e. the number of seconds since Jan. 1st 1970) var siteUID = 'uTtCGqDTEtcZMGL08w'; // siteUID should be taken from the new user record // you have stored in your DB in the previous step var yourSig = createSignature(siteUID, dateStr); var params = { siteUID: siteUID, timestamp:dateStr, cid:'', signature:yourSig }; // 3.1 call linkAccounts method: gigya.services.socialize.notifyRegistration(conf, params); } document.getElementById('status').style.color = "green"; document.getElementById('status').innerHTML = "Status: You are now signed in"; } // Note: the actual signature calculation implementation should be on server side function createSignature(UID, timestamp) { encodedUID = encodeURIComponent(UID); // encode the UID parameter before sending it to the server. // On server side use decodeURIComponent() function to decode an encoded UID return ''; } // Note: the actual signature calculation implementation should be on server side function verifyTheSignature(UID, timestamp, signature) { encodedUID = encodeURIComponent(UID); // encode the UID parameter before sending it to the server. // On server side use decodeURIComponent() function to decode an encoded UID alert('Your UID: ' + UID + '\n timestamp: ' + timestamp + '\n signature: ' + signature + '\n Your UID encoded: ' + encodedUID); } // Logout from Gigya platform. This method is activated when "Logout" button is clicked function logoutFromGS() { gigya.services.socialize.logout(conf, {/*no required params*/}); // logout from Gigya platform } // onLogout Event handler function onLogoutHandler(eventObj) { document.getElementById('status').style.color = "red"; document.getElementById('status').innerHTML = "Status: You are now signed out"; } </script> </head> <body onload="onLoad()"> <br /> <h4>Please sign in using one of the following providers:</h4><br /><br /> <div id="loginDiv"></div> <script type="text/javascript"> gigya.services.socialize.showLoginUI(conf, { height: 85 ,width: 360 ,showTermsLink:false // remove 'Terms' link ,hideGigyaLink:true // remove 'Gigya' link ,buttonsStyle: 'fullLogo' // Change the default buttons design to "Full Logos" design ,showWhatsThis: true // Pop-up a hint describing the Login Plugin, when the user rolls over the Gigya link. ,containerID: 'loginDiv' // The component will embed itself inside the loginDiv Div ,cid:'' }); </script> <br /> <br /><br /><br /> <h4>Click the button below to sign out from Gigya platform:</h4><br /><br /> <input id="btnLogout" type="button" value="Sign Out" onclick="logoutFromGS()"/> <br /> <br /> <div id="status"></div> </body> </html>
更多查看:
http://developers.gigya.com/040_Demos/038_Comments_Plugin
8. QQ
分享到QQ空间
<script type="text/javascript"> (function(){ var p = { url:location.href, desc:'',/*默认分享理由(可选)*/ summary:'',/*摘要(可选)*/ title:'',/*分享标题(可选)*/ site:'',/*分享来源 如:腾讯网(可选)*/ pics:'' /*分享图片的路径(可选)*/ }; var s = []; for(var i in p){ s.push(i + '=' + encodeURIComponent(p[i]||'')); } document.write(['<a href="http://sns.qzone.qq.com/cgi-bin/qzshare/cgi_qzshare_onekey?',s.join('&'),'" target="_blank" title="分享到QQ空间"><img src="http://qzonestyle.gtimg.cn/ac/qzone_v5/app/app_share/share_s.png" alt="分享到QQ空间" /></a>'].join('')); })(); </script>
分享到腾讯朋友
<script type="text/javascript"> (function(){ var p = { url:location.href, to:'pengyou', desc:'',/*默认分享理由(可选)*/ summary:'',/*摘要(可选)*/ title:'',/*分享标题(可选)*/ site:'',/*分享来源 如:腾讯网(可选)*/ pics:'' /*分享图片的路径(可选)*/ }; var s = []; for(var i in p){ s.push(i + '=' + encodeURIComponent(p[i]||'')); } document.write(['<a href="http://sns.qzone.qq.com/cgi-bin/qzshare/cgi_qzshare_onekey?',s.join('&'),'" target="_blank" title="分享到腾讯朋友"><img src="http://qzonestyle.gtimg.cn/ac/qzone_v5/app/qzshare/to-py.png" alt="分享到腾讯朋友" /></a>'].join('')); })(); </script>
分享:http://opensns.qq.com/share/
QQ登录:http://connect.opensns.qq.com/
QQ开发平台:http://opensns.qq.com/
QQ like:http://like.opensns.qq.com/
9. Reddit
<script type="text/javascript" src="http://www.reddit.com/static/button/button2.js?url=<?=url?>"></script>
http://www.reddit.com/buttons/
本站关联: