Reputation: 13545
My way to create a facebook share button is : 1. create a share.php (facebook capture meta data in this fake website and redirect to the actual website i want to share)
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:fb="https://www.facebook.com/2008/fbml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title><?php echo $_GET['title'];?></title>
<meta property="og:url" content="<?php echo $_GET['url'];?>" />
<meta property="og:title" content="<?php echo $_GET['title'];?>" />
<meta property="og:description" content="<?php echo $_GET['title'];?> "/>
<?
if (isset($_GET['leftImg']) && $_GET['leftImg'] != 'undefined') {
echo '<meta property="og:image" content="'.$_GET['leftImg'].'"/>';
}
if (isset($_GET['rightImg']) && $_GET['rightImg'] != 'undefined') {
echo '<meta property="og:image" content="'.$_GET['rightImg'].'"/>';
}
?>
</head>
<body>
<script>
window.location.href = "<?php echo $_GET['redirect'];?>";
</script>
</body>
</html>
2. The data need in share.php is passed from main page
window.open('http://www.facebook.com/sharer.php?u=' + encodeURIComponent('http://' + window.location.hostname + '/share.php?url=http://yahoo.com&title=test&redirect=..&leftImg=......&' ),'sharer','toolbar=0,status=0,width=826px,height=536');
The problem is , what should be the og:url? There are two link : the share.php and the actual website I want to share,
If I use share.php?title=...&description=.. , I still have to specific url and that is weird : it will be share.php?url=share.php?url=share.php and eventually I still can not reference the correct url for sharing
If I use the actual website, it can not collect any meta data, as my idea is all meta is on share.php
How to fix the problem ? thanks
!!!!!!!!!!!!!!!Updated on 11/4/2013:!!!!!!!!!!!!!!
I figured out the root problem , it is caused by different source of image:
eg. http://www.tekxon.com.pk/sites/all/themes/bluemasters/images/gallery/3.jpg
This image is capture by facebook on share page as expected, working flawlessly.
eg. http://54.251.107.161/source/test2/2012/05/07/0/3/A/Content/15/Pg015.png
This image ,hosted in my server , however, is not not shown on the share page as for the first time, but only when I reload the page. * Although it is not shown on the share page, the image is shown and exist on my share content in my facebook homepage.
Why is that happen , is it caused by some incorrect settings of firewall? thanks
Upvotes: 0
Views: 6582
Reputation: 1
you can follow the demo,wish you gook luck.
http://www.kimwoodbridge.com/how-to-create-your-one-facebook-share-url/
by the way,before you test new way. you had better clear the fb's session. http://developers.facebook.com/tools/debug/og/object?q=http://yourwebsite.com
Upvotes: 0
Reputation: 597
The og:url
should be the website that contains metadata - in this case you should make website with redirection and metadata or reference share.php?url=the_url.
Upvotes: 2
Reputation: 3748
I think you only have been misled by the og:url
parameter:
og:url
- The canonical URL of your object that will be used as its permanent ID in the graph
Sounds totally legit, but: When you specify that parameter, Facebook fetches the meta data from that URL instead from the current page. This is why you have no meta data when you put the referred URL there. And also the reason for that nasty share.php?url=share.php?url=share.php...
.
What you are trying to do is done using the href
attribute: https://developers.facebook.com/docs/reference/plugins/like/
I'm not sure what you are building, but maybe this way you even can integrate the share button into the page that you redirect to. Then you still set up that fake meta data page and just throw it into og:url
in that (formerly redirected to) page then :)
Upvotes: 1