Skip to content
pakainfo

Pakainfo

Web Development & Good Online education

  • Home
  • Blog
  • Categories
  • Tools
  • Full Form
  • Guest Post
    • Guest Posting Service
  • Advertise
  • About
  • Contact Us

how to Social Media Sharing Buttons in php?

November 19, 2020 Pakainfo php, JavaScript, jQuery, Programming Leave a comment

In this Post we will show you how to share your page or website in Social Media Sharing Buttons using php. This post we will share ,link on social media with title and url using php.

we will share Buffer, diggit, Email, Facebook, Google+, LinkedIn, Pinterest, Print, Reddit, StumbleUpon, Tumblr, Twitter, vkontakte and Yummly social media with php code.

For use this code of share button on social media, we have to pass url and title of url and pass in to give method of social media tab.

For use this code pass your site url and title in given variable $site_url and $site_title.

Social Media Sharing Buttons using php

Contents

  • Social Media Sharing Buttons using php
    • Pass your url and title in variable
  • Cool Social Share Buttons with Share Count Script for PHP
    • Related posts

CSS Code

#social_media_sharing_buttons img {
width: 36px;
box-shadow: 0;
padding: 6px;
display: inline;
border: 0;
}

Pass your url and title in variable

HTML & PHP Code

<?php 
    // pass web-site url
    $site_url  = "http://www.pakainfo.com/blog";
    // post title
    $site_title  = "pakainfo";
?>

<!-- <a> tab for http://www.pakainfo.com/blog share link for social media -->
<div id="social_media_sharing_buttons">
    
    <!-- Online Buffer Social Media -->
    <a href="https://bufferapp.com/add?url=<?=$site_url?>&text=<?=$site_title?>" target="_blank">
        <img src="http://www.pakainfo.com/example/images/buffer.png" alt="Buffer share link" />
    </a>
    
    <!-- Online Digg Social Media -->
    <a href="http://www.digg.com/submit?url=<?=$site_url?>" target="_blank">
        <img src="http://www.pakainfo.com/example/images/diggit.png" alt="Digg  share link" />
    </a>
    
    <!-- Online Email Social Media -->
    <a href="mailto:?Subject=<?=$site_title?>&Body=I%20saw%20this%20and%20thought%20of%20you!%20 <?=$site_url?>">
        <img src="http://www.pakainfo.com/example/images/email.png" alt="Email share link" />
    </a>
 
    <!-- Online Facebook Social Media -->
    <a href="http://www.facebook.com/sharer.php?u=<?=$site_url?>" target="_blank">
        <img src="http://www.pakainfo.com/example/images/facebook.png" alt="Facebook share link" />
    </a>
    
    <!-- Online Google+ Social Media -->
    <a href="https://plus.google.com/share?url=<?=$site_url?>" target="_blank">
        <img src="http://www.pakainfo.com/example/images/google.png" alt="Google share link" />
    </a>
    
    <!-- Online LinkedIn Social Media -->
    <a href="http://www.linkedin.com/shareArticle?mini=true&url=<?=$site_url?>" target="_blank">
        <img src="http://www.pakainfo.com/example/images/linkedin.png" alt="LinkedIn share link" />
    </a>
    
    <!-- Online Pinterest Social Media -->
    <a href="javascript:void((function()%7Bvar%20e=document.createElement('script');e.setAttribute('type','text/javascript');e.setAttribute('charset','UTF-8');e.setAttribute('src','http://assets.pinterest.com/js/pinmarklet.js?r='+Math.random()*99999999);document.body.appendChild(e)%7D)());">
        <img src="http://www.pakainfo.com/example/images/pinterest.png" alt="Pinterest share link" />
    </a>
    
    <!-- Print Social Media -->
    <a href="javascript:;" onclick="window.print()">
        <img src="http://www.pakainfo.com/example/images/print.png" alt="Print share link" />
    </a>
    
    <!-- Online Reddit Social Media -->
    <a href="http://reddit.com/submit?url=<?=$site_url?>&title=<?=$site_title?>" target="_blank">
        <img src="http://www.pakainfo.com/example/images/reddit.png" alt="Reddit share link" />
    </a>
    
    <!-- Online StumbleUpon Social Media -->
    <a href="http://www.stumbleupon.com/submit?url=<?=$site_url?>&title=<?=$site_title?>" target="_blank">
        <img src="http://www.pakainfo.com/example/images/stumbleupon.png" alt="StumbleUpon share link" />
    </a>
    
    <!-- Online Tumblr Social Media -->
    <a href="http://www.tumblr.com/share/link?url=<?=$site_url?>&title=<?=$site_title?>" target="_blank">
        <img src="http://www.pakainfo.com/example/images/tumblr.png" alt="Tumblr share link" />
    </a>
     
    <!-- Online Twitter Social Media -->
    <a href="https://twitter.com/share?url=<?=$site_url?>&text=Simple%20Share%20Buttons&hashtags=simplesharebuttons" target="_blank">
        <img src="http://www.pakainfo.com/example/images/twitter.png" alt="Twitter share link" />
    </a>
    
    <!-- Online vkontakte Social Media -->
    <a href="http://vkontakte.ru/share.php?url=<?=$site_url?>" target="_blank">
        <img src="http://www.pakainfo.com/example/images/vk.png" alt="VK share link" />
    </a>
    
    <!-- Online Yummly Social Media -->
    <a href="http://www.yummly.com/urb/verify?url=<?=$site_url?>&title=<?=$site_title?>" target="_blank">
        <img src="http://www.pakainfo.com/example/images/yummly.png" alt="Yummly share link" />
    </a>

</div>

index.html

<!DOCTYPE html>
<html>
<head>
<title>How To Style Social Media Buttons - www.pakainfo.com</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
<style>
.fa {
  padding: 20px;
  font-size: 30px;
  width: 50px;
  text-align: center;
  text-decoration: none;
  margin: 5px 2px;
}

.fa:hover {
    opacity: 0.7;
}

.fa-facebook {
  background: #3B5998;
  color: white;
}

.fa-twitter {
  background: #55ACEE;
  color: white;
}

.fa-google {
  background: #dd4b39;
  color: white;
}

.fa-linkedin {
  background: #007bb5;
  color: white;
}

.fa-youtube {
  background: #bb0000;
  color: white;
}

.fa-instagram {
  background: #125688;
  color: white;
}

.fa-pinterest {
  background: #cb2027;
  color: white;
}

.fa-snapchat-ghost {
  background: #fffc00;
  color: white;
  text-shadow: -1px 0 black, 0 1px black, 1px 0 black, 0 -1px black;
}

.fa-skype {
  background: #00aff0;
  color: white;
}

.fa-android {
  background: #a4c639;
  color: white;
}

.fa-dribbble {
  background: #ea4c89;
  color: white;
}

.fa-vimeo {
  background: #45bbff;
  color: white;
}

.fa-tumblr {
  background: #2c4762;
  color: white;
}

.fa-vine {
  background: #00b489;
  color: white;
}

.fa-foursquare {
  background: #45bbff;
  color: white;
}

.fa-stumbleupon {
  background: #eb4924;
  color: white;
}

.fa-flickr {
  background: #f40083;
  color: white;
}

.fa-yahoo {
  background: #430297;
  color: white;
}

.fa-soundcloud {
  background: #ff5500;
  color: white;
}

.fa-reddit {
  background: #ff5700;
  color: white;
}

.fa-rss {
  background: #ff6600;
  color: white;
}
</style>
</head>
<body>

<h2>Style Social Media Buttons - www.pakainfo.com</h2>
<a href="#" class="fa fa-rss"></a>
<a href="#" class="fa fa-vine"></a>
<a href="#" class="fa fa-skype"></a>
<a href="#" class="fa fa-yahoo"></a>
<a href="#" class="fa fa-vimeo"></a>
<a href="#" class="fa fa-tumblr"></a>
<a href="#" class="fa fa-flickr"></a>
<a href="#" class="fa fa-reddit"></a>
<a href="#" class="fa fa-google"></a>
<a href="#" class="fa fa-android"></a>
<a href="#" class="fa fa-youtube"></a>
<a href="#" class="fa fa-twitter"></a>
<a href="#" class="fa fa-dribbble"></a>
<a href="#" class="fa fa-linkedin"></a>
<a href="#" class="fa fa-facebook"></a>
<a href="#" class="fa fa-instagram"></a>
<a href="#" class="fa fa-pinterest"></a>
<a href="#" class="fa fa-foursquare"></a>
<a href="#" class="fa fa-stumbleupon"></a>
<a href="#" class="fa fa-snapchat-ghost"></a>
      
</body>
</html> 

Cool Social Share Buttons with Share Count Script for PHP

To add social media sharing buttons in PHP, you can use the social media APIs or third-party services that provide sharing buttons. Here’s a general overview of the process:

Also Read This 👉   javascript array length - How to Check if a JavaScript Array is Empty or Not with .length Example

Choose the social media platforms you want to support and obtain their API keys or access tokens if needed. Some platforms, like Twitter, allow for sharing without authentication, while others, like Facebook, require authentication through their API.

Use PHP to create the HTML and JavaScript code for the sharing buttons. This typically involves adding a link or button element for each platform, along with the appropriate URL for sharing and any necessary parameters.

Use JavaScript to add functionality to the sharing buttons, such as opening a pop-up window with the sharing URL and any necessary parameters.

Here’s an example of how to add a Twitter sharing button using PHP:

<a href="https://twitter.com/intent/tweet?url=<?php echo urlencode($url); ?>&text=<?php echo urlencode($text); ?>" target="_blank">
  <i class="fa fa-twitter"></i>
  Tweet
</a>

In this example, we’re using PHP to output an HTML anchor element that contains a link to the Twitter sharing URL. The urlencode function is used to encode the $url and $text parameters to ensure that they are properly formatted for the URL.

You can use similar code to add sharing buttons for other social media platforms. Note that some platforms may have specific requirements for sharing URLs and parameters, so be sure to consult their API documentation for more information. Additionally, you may want to consider using a third-party service, like AddThis or ShareThis, to simplify the process of adding social media sharing buttons.

I hope you get an idea about social share php code.
I would like to have feedback on my infinityknow.com blog.
Your valuable feedback, question, or comments about this article are always welcome.
If you enjoyed and liked this post, don’t forget to share.

Related posts:

  1. Sticky Social Media Floating Sidebar html
  2. How To Create Social Media icons footer using bootstrap?
  3. How to Guide on Scraping Social Media Data with PHP?
  4. 8 Free & Easy Photo Collage Makers for Social Media
  5. Previous and next buttons functionality in javascript
  6. Queen Daro : Age, Wiki, Biography – Pakistani-German TikTok & lip-syncing app social media star in 2023
  7. How to Show and Hide div elements using radio buttons?
  8. What social network apps are popular in the USA?
  9. Transparent black color and Opacity Color Codes
  10. how to set background image in php?
Also Read This 👉   Vuejs Restful Http Post and Get Web Api Calls
facebook share button code for websiteHow To Style Social Media Buttonshtml code for social media iconsjquery social share buttons plugin free downloadshare button generatorsocial media icons html generatorsocial media share scriptSocial Media Sharingsocial share buttons htmlsocial share php code

Post navigation

Previous Post:how to open wordpress dashboard in localhost xampp?
Next Post:Resolving the CodeIgniter “No Input File Specified” Error

Advertise With Us

Increase visibility and sales with advertising. Let us promote you online.
Click Here

Write For Us

We’re accepting well-written informative guest posts and this is a great opportunity to collaborate.
Submit a guest post to [email protected]
Contact Us

Freelance web developer

Do you want to build a modern, lightweight, responsive website quickly?
Need a Website Or Web Application Contact : [email protected]
Note: Paid Service
Contact Me

Categories

3movierulz (64) Ajax (464) AngularJS (377) ASP.NET (61) Bio (109) Bollywood (108) Codeigniter (175) CSS (98) Earn Money (93) Education (63) Entertainment (130) fullform (87) Google Adsense (64) Highcharts (77) History (40) Hollywood (109) JavaScript (1359) Jobs (42) jQuery (1423) Laravel (1088) LifeStyle (53) movierulz4 (63) Mysql (1035) Mysqli (894) php (2133) Programming (2345) Python (99) Software (178) Software (90) Stories (98) tamilrockers (104) Tamilrockers kannada (64) Tamilrockers telugu (61) Tech (147) Technology (2416) Tips and Tricks (130) Tools (214) Top10 (507) Trading (95) Trending (77) VueJs (250) Web Technology (113) webtools (200) wordpress (166) World (343)

A To Z Full Forms

Access a complete full forms list with the meaning, definition, and example of the acronym or abbreviation.
Click Here
  • Home
  • About Us
  • Terms And Conditions
  • Write For Us
  • Advertise
  • Contact Us
  • Youtube Tag Extractor
  • Info Grepper
  • Guest Posting Sites
  • Increase Domain Authority
  • Social Media Marketing
  • Freelance web developer
  • Tools
Pakainfo 9-OLD, Ganesh Sco, Kothariya Ring Road, Chokadi, Rajkot - 360002 India
E-mail : [email protected]
Pakainfo

© 2023 Pakainfo. All rights reserved.

Top
Subscribe On YouTube : Download Source Code
We accept paid guest Posting on our Site : Guest Post Chat with Us On Skype Guest Posting Sites