Social Media Share: I built something really cool but I need help finishing 2 things?

Social Media Share: I built something really cool but I need help finishing 2 things? Here is the link http://www.visibilityinherit.com/projects/social-test.php

I posted this here because its a little php, js, and html. This shares the current webpage using the six most used social services and uses php to populate the url, title, and body text when applicable. This way I dont slow down my site with js 3rd party plugins and I can use my own buttons. But I have two remaining things left I cant figure out.

  1. When I share with Pinterest I would like it to pull from the current pages available pictures and title of page. Currently I have to give a default for the title and the image. It does however use the current page url. So I need some magic php to populate all three in a post.

  2. I would like each to pop up in a fancybox lightbox when clicked. The fancybox works and pops up but displays nothing (its code is not currently within the test page). If I link to another page (like sitepoint) then it works perfectly. So it makes me believe its something to do with the link/url format/structure for the posts. Anyone know a fix for that?

Thanks! Code…


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>This is a test of a title</title>
<style type="text/css">
a {display:block;}
</style> 
</head>
<body>

<?php
if ($_SERVER["HTTPS"] == "on") { $full_url = 'https://'; }
else { $full_url = 'http://'; }
if ($_SERVER["SERVER_PORT"] != "80") {
    $full_url .= $_SERVER["SERVER_NAME"].":".$_SERVER["SERVER_PORT"].$_SERVER["REQUEST_URI"];
} else {
    $full_url .= $_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"];
}
 
// Facebook
echo "<a href=\\"http://www.facebook.com/sharer.php?u= ". urlencode($full_url) ." &t=Page Title\\">Facebook</a>";

// Twitter
echo "<a href=\\"http://twitter.com/home?status=Check out ". urlencode($full_url) ." \\">twitter</a>";

// Google+
echo "<a href=\\"https://plus.google.com/share?url=". urlencode($full_url) ." \\">Google+</a>";

// linkedin
echo "<a href=\\"http://www.linkedin.com/shareArticle?mini=true&url=". urlencode($full_url) ."&title=". urlencode($full_url) ."&source= \\">linkedin</a>";

// Pinterest
echo "<a href=\\"http://pinterest.com/pin/create/button/?url=http%3A%2F%2Fwww.yourdomain.com%2F&media=http%3A%2F%2Fwww.yourdoamin.com%2Fimage.jpg&description=Your%20Biz%20Name%20Here%20in%20City%2C%20State%20". urlencode($full_url) ."%2F \\">Pinterest</a>";
?>

<script language="javascript">
function mailpage()
{
mail_str = "mailto:?subject=Check out the " + document.title;
mail_str += "&body=I thought you might be interested in the " + document.title;
mail_str += ". You can view it at, " + location.href;
location.href = mail_str;
}
</script>
<a href="javascript:mailpage()">Email</a>

<p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Quisque tempor. Nam in libero vel nisi accumsan euismod. Quisque quis neque. Donec condimentum, enim convallis vestibulum varius, quam mi accumsan diam, sollicitudin ultricies odio ante vitae purus. Etiam ultricies quam. Vestibulum turpis turpis, fermentum ut, accumsan quis, tempor at, ipsum. Nam felis elit, sollicitudin id, ultrices faucibus, fringilla vel, dui. Aliquam tincidunt iaculis eros. Sed in lorem. Nullam eu enim. Quisque tristique pretium diam. Fusce tempor sollicitudin ligula. Donec purus eros, mattis quis, mattis vestibulum, congue quis, felis. Nulla facilisi. Nam ultricies posuere justo. In feugiat.</p>

<p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Quisque tempor. Nam in libero vel nisi accumsan euismod. Quisque quis neque. Donec condimentum, enim convallis vestibulum varius, quam mi accumsan diam, sollicitudin ultricies odio ante vitae purus. Etiam ultricies quam. Vestibulum turpis turpis, fermentum ut, accumsan quis, tempor at, ipsum. Nam felis elit, sollicitudin id, ultrices faucibus, fringilla vel, dui. Aliquam tincidunt iaculis eros. Sed in lorem. Nullam eu enim. Quisque tristique pretium diam. Fusce tempor sollicitudin ligula. Donec purus eros, mattis quis, mattis vestibulum, congue quis, felis. Nulla facilisi. Nam ultricies posuere justo. In feugiat.</p>

<p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Quisque tempor. Nam in libero vel nisi accumsan euismod. Quisque quis neque. Donec condimentum, enim convallis vestibulum varius, quam mi accumsan diam, sollicitudin ultricies odio ante vitae purus. Etiam ultricies quam. Vestibulum turpis turpis, fermentum ut, accumsan quis, tempor at, ipsum. Nam felis elit, sollicitudin id, ultrices faucibus, fringilla vel, dui. Aliquam tincidunt iaculis eros. Sed in lorem. Nullam eu enim. Quisque tristique pretium diam. Fusce tempor sollicitudin ligula. Donec purus eros, mattis quis, mattis vestibulum, congue quis, felis. Nulla facilisi. Nam ultricies posuere justo. In feugiat.</p>

</body>
</html>

Yes, the Pinterest button is a tricky one. Here are two links I found useful:

http://stackoverflow.com/questions/9509600/populate-pinterest-pin-it-button-with-php

http://automateeverything.tumblr.com/post/19106283833/pinterest-pin-it-button-implementation-problems-and

It seems to me you have your URL bit in the wrong place for the Pinterest code you have posted. It should come after url=, I would have thought.

thnaks ralph. Ya i’ve read pretty much everything on the web about it. As usual most things I try and do aren’t on it. Search “auto populate pinterest url post”. I tried every php solution I found on the web. None worked. The second link is using js. No js. This one looks promising but it threw an error. Dont know how to fix it.

<?php
//This code generates the Pinterest social sharing button and auto-populates the URL and the image of the product

$url= ‘<a href="http://pinterest.com/pin/create/button/?url=’;
$pageaddr= curPageURL();
$urlend = ‘class=“pin-it-button” count-layout=“horizontal”>Pin It</a>’;
$imageurl = ‘http://yoursite.com/images’ . $product_info[‘products_image’] ;
$newurl = $url . $pageaddr .‘&media=’ . $imageurl . ‘"’ . $urlend;
echo ($newurl);
?>
<script type=“text/javascript” src=“http://assets.pinterest.com/js/pinit.js”></script>

seen here http://forums.oscommerce.com/topic/384885-pinterest-pin-it-button/