I have a image tag that gets a php variable from another page,
<img src="<?php echo urldecode($_GET['pic']); ?>" width="100%" alt="" />.
It works fine. I would like to know how to take that and make it work with the meta tags og:image and itemprop="image". I've tried several ways, but had no luck.
Thanks,
Darrell
It needs to be in the HTML head.
Here is a modified example from http://ogp.me/
<html prefix="og: http://ogp.me/ns#">
<head>
<title>The Rock (1996)</title>
<meta property="og:title" content="The Rock" />
<meta property="og:type" content="video.movie" />
<meta property="og:url" content="http://www.imdb.com/title/tt0117500/" />
<meta property="og:image" content="<?php echo urldecode($_GET['pic']); ?>" />
...
</head>
...
</html>
Related
I want to share a link on Google plus posts with parameters Title, Image and Description.
But even this simple code doesn't work for me.
Issue is that:
Image is not shown,
Title is not shown,
Description is not shown.
For Test Purpose here is the link of of site for this code.
http://getreferralace.com/gonawazgo.php
<html>
<head>
<title>Basic page</title>
<link rel="canonical" href="http://www.getreferralace.com/campagins_view?id=21" />
<meta property="og:title" content="This is Referral Ace" />
<meta property="og:description" content="This is decription for Referral Ace" />
<meta property="og:url" content="http://www.getreferralace.com/campagins_view?id=21" />
<meta property="og:image" content="http://www.getreferralace.com/campaign_images/Tulips.jpg" />
<script type="text/javascript" src="https://apis.google.com/js/plusone.js">
</script>
</head>
<body>
Share
</body>
</html>
Your href tag is not sharing the correct link to google plus:
The link your sharing is: http://www.getreferralace.com/campagins_view?id=21 which results in a 404 error page.
So you can use the below link:
Share
Discription is not shown.
Everthing else is working fine.
<html>
<head>
<title>Basic page</title>
<link rel="canonical" href="http://www.getreferralace.com/gonawazgo.php" />
<meta property="og:title" content="This is Referral Ace" />
<meta property="og:description" content="This is decription for Referral Ace" />
<meta property="og:url" content="http://www.getreferralace.com/gonawazgo.php" />
<meta property="og:image" content="http://www.getreferralace.com/campaign_images/Tulips.jpg" />
<script type="text/javascript" src="https://apis.google.com/js/plusone.js">
</script>
</head>
<body class="body_style" itemscope itemtype="http://schema.org/Product">
<div class="abc" style="display: none;">
<h1 itemprop="name">Title Pizza</h1>
<img itemprop="image" src="http://www.getreferralace.com/campaign_images/Tulips.jpg" />
<p itemprop="description">This is decription for Referral Ace</p>
</div>
Share
</body>
</html>
</html>
I am trying to make a facebook share button popup within the same page to share a specific link based on the specific url , i used this code and it works but all it gives me is the url. I would like it to look like this
my current code i have is this
<li> <a
id="fb-share"
style='text-decoration:none;'
type="icon_link"
onClick="window.open(
'http://www.facebook.com/sharer.php?s=100&p[title]=YOUR_TITLE&p[summary]='
+ 'YOUR_DESCRIPTION&p[url]=YOUR_URL&p[images][0]=YOUR_IMAGE',
'sharer',
'toolbar=0,status=0,width=580,height=325');"
href="javascript: void(0)"
>
<img class="logo" src="images/facebook.png" width="60" height="50" alt="Our Facebook Page "></a></li>
it only displays the correct url.Not the title , description or image. The images, and description and title comes from the db
<meta property="og:title" content="<?php echo title; ?>">
the other issue is the
<meta property="og:image"
must this be a url or can it come from the db similar to the og:title? as each main image must be displayed differently based on specific url.
i currently have this , will this be able to display the image , i do see the image name
<?php echo '<meta property="og:image" content="' . $image . '"/>'; ?>
Expected OG tags format,
<html prefix="og: http://ogp.me/ns#">
<head>
<title>The Rock (1996)</title>
<meta property="og:title" content="The Rock" />
<meta property="og:type" content="video.movie" />
<meta property="og:url" content="http://www.imdb.com/title/tt0117500/" />
<meta property="og:image" content="http://ia.media-imdb.com/images/rock.jpg" />
...
</head>
...
</html>
Read more
I've got a share button that I am trying to modify to my specific needs. Here is the code.
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:og="http://ogp.me/ns#"
xmlns:fb="http://www.facebook.com/2008/fbml">
<html>
<meta property="fb:app_id" content="lotsanumbers" />
<meta property="og:title" content="FOR SALE"/>
<meta property="og:type" content="product"/>
<meta property="og:url" content="http://www.website.com.au/php_test.php"/>
<meta property="og:image" content="http://www.website.com.au/ddfut14-1148.jpg"/>
<meta property="og:description" content="http://www.website.com.au/php_test.php<?php echo $title; ?>" />
Everything is working as requires except for the og:description. When I debug in facebook facebook is only seeing
<meta property="og:description" content="http://www.website.com.au/php_test.php
it is not scraping
<?php echo $title; ?>
from the same line what am I missing?
og:description is a tag that should contain text, you should be doing like:
<meta property="og:description" content="<?php echo $title; ?>" />
//where $title should be a defined variable that contains some text
or
<meta property="og:description" content="<?php echo file_get_contents("http://www.website.com.au/php_test.php"); ?>" />
//where your php_test.php file should echo out text
I got a wordpress "single-page" with different posts on it, that doesnt need to reload. A post is loaded in when you click on a post name without reloading the whole page.
All posts have a individual ID & subURL though. Each post also has share buttons for facebook, twitter, google+, linkedin and xing.
I want to provide the shares with the information about the individual post the user wants to share, for example ID, image, some text content and so on.
This is what my share buttons look like atm:
<div class="share-twitter">
<img src="exampleimg.jpg">
</div>
Now I read in another article here on stackoverflow that i should use meta tags to give them the information.
This is how i tried to do this:
<!-- for Google -->
<meta name="description" content="<?php the_content();?>" />
<meta name="keywords" content="app" />
<meta name="author" content="<?php the_author();?>" />
<meta name="copyright" content="corporate name" />
<meta name="application-name" content="<?php the_title();?>" />
<!-- for Facebook -->
<meta property="og:title" content="<?php the_title();?>" />
<meta property="og:type" content="article" />
<meta property="og:image" content="imgexample.png" />
<meta property="og:url" content="http://example.de/%23/?p=<?php the_id();?>/<?php the_title();?>" />
<meta property="og:description" content="<?php the_content();?>" />
<!-- for Twitter -->
<meta name="twitter:card" content="summary" />
<meta name="twitter:title" content="<?php the_title();?>" />
<meta name="twitter:description" content="<?php the_content();?>" />
<meta name="twitter:image" content="imgexample.png" />
Well, my actual problem now is that the meta tags I added change nothing. the link URL is provided correctly as before, cause i already do this with href, but it still uses a random img of the page, no content provided or anything else I provided over the meta tags...
Any clues why this doesnt work?
Try this:
<php if(is_single()) { ?>
<meta property="og:image" content="<?php $image = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), '' ); ?>" />
<?php } else { ?>
<meta property="og:image" content="imgexample.png" />
I have a dynamic PHP page that basically displays a video. When a Facebook user clicks on the video, a timeline event is posted to their Facebook profile, but my OG meta tags don't seem to want to cooperate with the PHP variables the video information is stored in.
If I type the correct strings directly into the meta tags, everything works great, but the page by design picks a video from my Database.
These are the current tags with PHP Variables included:
<head prefix='og: http://ogp.me/ns# fb: http://ogp.me/ns/fb# visiovert: http://ogp.me/ns/fb/visiovert#'>
<meta property='fb:app_id' content='261459743887413'>
<meta property='og:type' content='visiovert:advertisement'>
<meta property='og:url' content='http://visiovert.net/ad.php'>
<meta property='og:site_name' content='VisioVert'>
<?php
echo("<meta property=\"og:title\" content=\"".$Video->title."\" />\n");
echo("<meta property=\"og:description\" content=\"".$Video->description."\" />\n");
echo("<meta property=\"og:image\" content=\"".$Video->location.".jpg\" />\n");
echo("<meta property=\"og:video\" content=\"".$Video->location.".mp4\" />\n");
?>
<meta property='og:video:height' content='432' >
<meta property='og:video:width' content='768'>
</head>
If you view the page source, this is what you can see in the header:
<head prefix='og: http://ogp.me/ns# fb: http://ogp.me/ns/fb# visiovert: http://ogp.me/ns/fb/visiovert#'>
<meta property='fb:app_id' content='261459743887413'>
<meta property='og:type' content='visiovert:advertisement'>
<meta property='og:url' content='http://visiovert.net/ad.php'>
<meta property='og:site_name' content='VisioVert'>
<meta property="og:title" content="Echo" />
<meta property="og:description" content="An example video ad for VisioVert." />
<meta property="og:image" content="http://visiovert.net/Videos/echo.jpg" />
<meta property="og:video" content="http://visiovert.net/Videos/echo.mp4" />
<meta property='og:video:height' content='432' >
<meta property='og:video:width' content='768'>
</head>
That matches exactly what I would like it to, but when testing using the Facebook Object Debugger, it is not getting anything out of PHP variables. I could be missing something right in front of me...but I've looked around and haven't found an answer.
Veliisx
try adding fb namespace to your html tag.
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:fb="http://www.facebook.com/2008/fbml" xmlns:og="http://ogp.me/ns#" xmlns:shawnsspace="http://www.shawnsspace.com/ns#">
p.s. in your source only half of the tags are closed. Not sure if this would be ignored but will cause errors in some browsers.
I often have issues with escaping too, have you tried something like below to avoid the heavy escaping?
The below is basicly how dynamically add my meta, i know its a bit more code to echo each but it avoids a lot of confusion with escaping.
<head prefix='og: http://ogp.me/ns# fb: http://ogp.me/ns/fb# visiovert: http://ogp.me/ns/fb/visiovert#'>
<meta property='fb:app_id' content='261459743887413'>
<meta property='og:type' content='visiovert:advertisement'>
<meta property='og:url' content='http://visiovert.net/ad.php'>
<meta property='og:site_name' content='VisioVert'>
<meta property="og:title" content="<?php echo $Video->title; ?>" />
<meta property="og:description" content="<?php echo $Video->description; ?>" />
<meta property="og:image" content="<?php echo $Video->location; ?>.jpg" />
<meta property="og:video" content="<?php echo $Video->location; ?>.mp4" />
<meta property='og:video:height' content='432' >
<meta property='og:video:width' content='768'>
</head>