Homepage › Forums › Articles › Programming › PHP › Social Sharing Links Code Snippets
This topic was published by DevynCJohnson and viewed 2348 times since "". The last page revision was "".
Viewing 1 post (of 1 total)
- AuthorPosts
Numerous websites have social bookmarking and sharing links. Obviously, many web developers want to add social sharing links and bookmarking links to their web-pages. Below are code snippets for adding these links to PHP code. If static (plain HTML) code is desired, then replace the single-quotes, concatenation periods, and the PHP variables with the desired static data.
PHP Variables
- Page Title -
$EN_TITLE=urlencode(get_the_title());
- Page URL -
$EN_URL=urlencode('http://'.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']);
- Site Link -
$EN_SITE=urlencode('https://dcjtech.info/');
Social Sharing Code
- Delicious - `Delicious`
- Design Float - `Design Float`
- Digg - `Digg`
- Facebook - `Facebook`
- Google+ - `Google+`
- LinkedIn - `LinkedIn`
- MySpace - `MySpace`
- Newsvine - `Newsvine`
- Pinterest - `Pinterest`
- Reddit - `Reddit`
- StumbleUpon - `StumbleUpon`
- Tumblr - `Tumblr`
- Twitter - `Twitter`
Usage Example
DCJTech uses the below code for its social sharing links.
<div class="share sharing"><h6>Share</h6> <?php $EN_TITLE=urlencode(get_the_title()); $EN_URL=urlencode('http://'.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']); $EN_SITE=urlencode('https://dcjtech.info/'); echo '<a href="http://del.icio.us/post?url='.$EN_URL.'&title='.$EN_TITLE.'" target="_blank">Delicious</a> | <a href="http://www.designfloat.com/submit.php?url='.$EN_URL.'&title='.$EN_TITLE.'" target="_blank">Design Float</a> | <a href="http://digg.com/submit?url='.$EN_URL.'&title='.$EN_TITLE.'" target="_blank">Digg</a> | <a href="https://www.facebook.com/sharer/sharer.php?u='.$EN_URL.'" target="_blank">Facebook</a> | <a href="https://plus.google.com/share?url='.$EN_URL.'" target="_blank">Google+</a> | '; echo '<a href="https://www.linkedin.com/shareArticle?mini=true&url='.$EN_URL.'&source='.$EN_SITE.'" target="_blank">LinkedIn</a> | <a href="http://www.myspace.com/Modules/PostTo/Pages/?u='.$EN_URL.'&t='.$EN_TITLE.'" target="_blank">MySpace</a> | <a href="http://www.newsvine.com/_tools/seed&save?u='.$EN_URL.'&h='.$EN_TITLE.'" target="_blank">Newsvine</a> | <a href="https://www.pinterest.com/pin/create/button/?url='.$EN_URL.'" target="_blank">Pinterest</a> | '; echo '<a href="http://reddit.com/submit?url='.$EN_URL.'&title='.$EN_TITLE.'" target="_blank">Reddit</a> | <a href="http://www.stumbleupon.com/submit?url='.$EN_URL.'&title='.$EN_TITLE.'" target="_blank">StumbleUpon</a> | <a href="http://www.tumblr.com/share?v=3&u='.$EN_URL.'&t='.$EN_TITLE.'" target="_blank">Tumblr</a> | <a href="https://twitter.com/intent/tweet/?text='.$EN_TITLE.'&url='.$EN_URL.'&via=DevynCJohnson" target="_blank">Twitter</a> | '; echo '<a href="javascript:window.print();" title="Print page">Print</a>';?> </div>
- Page Title -
- AuthorPosts
Viewing 1 post (of 1 total)