PHP – Facebook Sharer


<html>
<title>Hello My Share <?php echo date('m/d/Y h:i:s a', time());?> Title Tag</title>
<meta name="description" content="The Share WEB FB - meta description">
<meta name="author" content="G3n1k - meta author">
<meta name="image" content="http://squareteam.co/dev/g3n1k/fb/khansa.jpg">
</html>
<body>
<?php
// http://www.joshuawinn.com/facebooks-sharer-php-longer-deprecated-2014/
function getUrl() {
$url = isset( $_SERVER['HTTPS'] ) && 'on' === $_SERVER['HTTPS'] ? 'https' : 'http';
$url .= '://' . $_SERVER['SERVER_NAME'];
$url .= in_array( $_SERVER['SERVER_PORT'], array('80', '443') ) ? '' : ':' . $_SERVER['SERVER_PORT'];
$url .= $_SERVER['REQUEST_URI'];
return $url;
}

$encoded_url = urlencode( getUrl() );

if ( !empty($encoded_url) ){ ?>
<center>
<a href="https://www.facebook.com/sharer/sharer.php?u=<?php echo $encoded_url; ?>" target="_blank">
Share this page on Facebook
</a>
</center>
<?php } ?>
</body>

<a href=’http://squareteam.co/dev/g3n1k/fb/sharefb.php’>http://squareteam.co/dev/g3n1k/fb/sharefb.php</a&gt;

Published by

G3n1k

just to remember what i had known :)

One thought on “PHP – Facebook Sharer”

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s