how to create a content sharing service like Tweet button or Facebook share
I am implementing a content sharing service, similar to Twitter and Facebook button. When the user visits a page, he will be able to click on my button, which will open a page in a new window that lets the user interact with my service. My service use 2 parameters: the current page's URL and title.
I have looked at the html code used to add the Twitter, Facebook and Printfriendly buttons and they all use Javascript code specific to their service. For instance, this JS file must be included to add the Printfriendly button to your page:
<script src="http://cdn.printfriendl开发者_如何学Pythony.com/printfriendly.js" type="text/javascript"></script>
For Facebook: <script src="http://static.ak.fbcdn.net/connect.php/js/FB.Share" type="text/javascript"></script>
Twitter:<script type="text/javascript" src="http://platform.twitter.com/widgets.js"></script>
My question is do I need to write some Javascript code or can I just forward all the request to the server?
Thanks,
Olivier.
You need to write a bit of JavaScript code for the button (for the window to show up with the specified contents) and the main script (which is included like Twitter and facebook did as you mentioned)
You can get away with simple hyperlink. For example Facebook share button works like hyperlink: <a href="http://www.facebook.com/share.php?u=http://www.shredsite.com/&t=Title">Share on Facebook</a>
.
The reason to use javascript or iframe is to have better control over user experience. So it is up to you to decide how you want to handle it.
精彩评论