Open Graph Tags automatic - facebook-opengraph

My website has lots of seperate articles and I need a way to automatically create the OG tags for each notice.
I have filled the OG tags, but it seems wrong while testing it on FB debugger.
Code below:
<meta property="og:site_name" content="Site Name (Can be Static)"/>
<meta property="og:type" content="article"/>
<meta property="og:title" content="<?php echo $title;?>"/>
<meta property="og:description" content="<?php echo $content;?>" />
<meta property="og:url" content="http://url.com/index.php?action=show&type=<?php echo $type;?>&id=<?php echo $id;?>"/>
<meta property="og:image" content="something.php" />
<meta property="fb:admins" content="someid"/>
Notice attributes:
Title = $title
Content = $content
Notice type = $type
ID = $ID
It's all dynamic.
How to fix that??
Thanks

Have you add that line too ?
<head prefix="og: http://ogp.me/ns# fb: http://ogp.me/ns/fb# http://ogp.me/ns/fb/[your name space]#">
Which kind of error do you get from the Linter ?

Related

Content of meta tag not get fetched by Crawler

I am working on a Wordpress plugin to post WordPress post on Fb as an SWF video.
I was able to post to FB and worked perfectly before 14-05-15. But Now when I make a post, it is only posting the link of the page*.
When I debug it with https://developers.facebook.com/tools/debug it is showing a critical error
"Error parsing input url,No data was cached or no data was scrapped".
On clicking "Fetch New Scrape Information" it is showing two critical Errors.
"Error parsing input url, No data was cached or no data was scrapped"*
and
CURL Error:RECV_ERROR receieved HTTP code 502 from proxy after connect*
Again When I click "Fetch New Scrape Information" All the meta tags get fetched and showing my Post.
When I Refresh Share attachment,It will displayed perfectly. But I needed to show this from the first time when I post from WP.
<meta property="og:title" content="<?php echo $data['title']; ?>" />
<meta property="og:type" content="website"/>
<meta property="og:description" content="<?php echo $data['descripton']; ?>" />
<meta property="og:image" content="<?php echo $data["preview_img"]; ?>" />
<meta property="og:image:width" content="300" />
<meta property="og:image:height" content="300" />
<meta property="og:site_name" content="<?php echo $data['title']; ?>"/>
<meta property="og:video" content="<?php echo WPFBAP_SWF.'fbap.swf?wpContent='.urlencode($data["content"]).'&bg_clr='.$data["bg_color"].'&bg_image='.$data["bg_image"].'&font_color='.$data["font_color"].'&repeat='.$data["image_fill"].'&video_url='.$data["video_id"]; ?>" />
<meta property="og:video:type" content="application/x-shockwave-flash">
<meta property="og:video:width" content="400">
<meta property="og:video:height" content="360">
These are the meta tags I am using. What is Wrong ?

EzPublish legacy - Fetching Meta tags

So i have my main meta tags e.g keywords, description..
But on specific sites i want to add a class named metatags where i can insert individual meta tags for the site.
Now my problem is that i don't know how to fetch those. I need a fallback so when i don't have my metatags class, the standard metatags will be used. But when i have my metatags class added they should be shown as well.
I tried it like this and wrote into the section on the pagelayout.tpl :
{let node_metas=fetch(content, node, hash(node_id, $module_result.node_id))}
{if eq( $node_metas.object.data_map.meta_description.content,""}
<meta name="description" content="{$site.meta.description|wash}">
{else}
<meta name="description" content="{$node_metas.object.data_map.meta_description.content|wash}">
{/if}
{if eq( $node_metas.object.data_map.meta_keys.content,""}
<meta name="keywords" content="{$site.meta.keywords|wash}">
{else}
<meta name="keywords" content="{$node_metas.object.data_map.meta_keys.content|wash}">
{/if}
{/let}
Does anyone have an idea why it's not working? I'm still new to ezpublish so i'm thankful for any help !
try this in your page_head.tpl
{def $currentNode = fetch( 'content', 'node', hash( 'node_id', ezpagedata().node_id ))}
{if $currentNode.data_map.meta_tag_description.has_content}
<meta name="description" content="{$currentNode.data_map.meta_tag_description.content|wash}">
{else}
<meta name="description" content="{$site.meta.description|wash}">
{/if}

Facebook not showing thumbnail nor title when sharing an article from wordpress

this last two days, we are encoutring problems with our links: When we want to share a link in facebook, it does not recognize it ( it shows no thmbnail nor the title) .
The facebook's debugger (shows the following error: "URL requested a HTTP redirect, but it could not be followed."
and for the URL "http://www.ozap.tv/decouvrez-nouveau-teaser-du-galaxy-s6/" it gives the canonical URL "http://www.ozap.tv/SleUZ/decouvrez-nouveau-teaser-du-galaxy-s6/" which means it adds SIeUZ
for some others the debugger shows the error: "Could not resolve the hostname into a valid IP address." and the canonical URL is correct.
the article that we published before those two days works fine.
The problem went after having edited some code.
We are trying to guess the issue of the problem and we want to know if it is related to the DNS, the code or the host server
any help
Cordially
not sure if this is causing the error but in your code, you have duplicate og meta data tags.
<!-- This site is optimized with the Yoast WordPress SEO plugin v1.6.3 - https://yoast.com/wordpress/plugins/seo/ -->
<meta name="description" content="Découvrez le nouveau teaser du Galaxy S6 !"/>
<link rel="canonical" href="http://www.ozap.tv/decouvrez-nouveau-teaser-du-galaxy-s6/" />
<meta property="og:locale" content="fr_FR" />
<meta property="og:type" content="article" />
<meta property="og:title" content="Découvrez le nouveau teaser du Galaxy S6 !" />
<meta property="og:description" content="Découvrez le nouveau teaser du Galaxy S6 !" />
<meta property="og:url" content="http://www.ozap.tv/decouvrez-nouveau-teaser-du-galaxy-s6/" />
<meta property="og:site_name" content="Ozap" />
<meta property="article:section" content="Actualités" />
<meta property="article:published_time" content="2015-02-19T09:31:40+00:00" />
<meta property="og:image" content="http://www.ozap.tv/wp-content/uploads/2015/02/next-galaxy-charging.jpg" />
<meta property="og:image" content="http://images.frandroid.com/wp-content/uploads/2015/02/s6-puissance-teaser-630x232.png" />
<!-- / Yoast WordPress SEO plugin. -->
and
<meta property="og:site_name" content="Ozap" />
<meta property="og:type" content="article" />
<meta property="og:url" content="http://www.ozap.tv/decouvrez-nouveau-teaser-du-galaxy-s6/" />
<meta property="og:title" content="Découvrez le nouveau teaser du Galaxy S6 !" />
<meta property="og:description" content="La vague de teasing orchestrée la semaine dernière par Samsung évoquait les capacités photo du futur Galaxy (S6) dont l’annonce est prévue au prochain Mobile World Congress. Cette semaine, le Coréen c" />
<meta property="og:image" content="http://www.ozap.tv/wp-content/uploads/2015/02/next-galaxy-charging.jpg" />
This could confuse Facebook as this is where Facebook gets the information from.
*Edit
Another strange thing that I picked up is the following redirect:
Checked link: http://www.ozap.tv/decouvrez-nouveau-teaser-du-galaxy-s6/
Type of redirect: 302 Found
Redirected to: http://www.ozap.tv/QYWSZ/decouvrez-nouveau-teaser-du-galaxy-s6/
i reviewed the code in wordpress
the first bloc of code is written by Yoast SEO plugin
the second one is written by a function in the file function.php
Now that i've desabled the Yoast SEO plugin, i can share articles after using the debugger tool. i put the URL of the article and i click "Fetch new scrape information".
After desabling Yoast SEO, the problem of redirecting is resolved, as it seems.
Is that a problem in the cach of facebook?
i'm returning to that issue again. I need to have the Yoast SEO plugin and i need to use facebook widget too, so i have to solve the issue differently. i'm wondering if i delete the function i was talking about from the file "function.php", and if i install those widget and plugin again, would i encouter the same issue again (duplacating the ogtags)
function dp_fb_ogtags(){
$site_name = esc_attr(get_option('blogname'));
$type = is_front_page() ? 'website' : 'article';
$url = get_permalink();
$title = wp_title( '|', false, 'right' );
$desc = dp_get_doc_desc();
$image = '';
$admins = '';
// Get image
if (is_singular()) {
global $post;
// Get image by feature image
$image = dp_thumb_url('large', false, $post->ID);
// Get image from post attachments
if(empty($image) && $images = get_children('post_type=attachment&post_mime_type=image&post_parent='.$post->ID))
if (is_array($images) && !empty($images))
$image = wp_get_attachment_thumb_url(current($images)->ID);
// Get first image from post content
if(empty($image) && preg_match('/<img[^>]*src=([\'"])(.*?)\\1/i', $post->post_content, $matches))
$image = $matches[2];
}
// Generate meta tags
$nl = "\n";
$tags = '';
$tags .= '<meta property="og:site_name" content="'.$site_name.'" />'.$nl;
$tags .= '<meta property="og:type" content="'.$type.'" />'.$nl;
$tags .= '<meta property="og:url" content="'.$url.'" />'.$nl;
if($title)
$tags .= '<meta property="og:title" content="'.$title.'" />'.$nl;
if($desc)
$tags .= '<meta property="og:description" content="'. esc_attr($desc).'" />'.$nl;
if($image)
$tags .= '<meta property="og:image" content="'.$image.'" />'.$nl;
if($admins)
$tags .= '<meta property="fb:admins" content="'.esc_attr($admins).'" />'.$nl;
echo $tags;//*/
}

Dynamically change og:description dynamically with php

Hi I´m having a hard time getting my og metatags to change dynamically( banging my head against the wall). I want to change the og:description dynamically based on an input field.
Here is what I have been able do figure out so far:
$og_description = $_POST['question'];
$custom_input = array("value" => $og_description);
<meta property="fb:app_id" content="xxxxxxxxxxxxxx" />
<meta property="og:site_name" content="Site name etc.. " />
<meta property="og:description" content=" <?php echo "this is {$custom_input['value']} !"; ?>" />
It works just fine outside the meta tags, but for some reason I just end up with it echoing the text "this is".
Any help would be greatly appreciated:)

Linting Ajax URLs

I noticed a weird behaviour while testing linting Ajax URLs. A simple tech test can be found at http://jankrems.de/hashbang/#!/foo.php
When I lint http://jankrems.de/hashbang/foo.php directly, everything works fine: http://cl.ly/3f3t2c0i3M3t0x2Q1Z3l
When I lint the Ajax-Url http://jankrems.de/hashbang/#!foo.php there's some pretty strange output: http://cl.ly/3n3e0r1s122Q1L0U033k
I tried linting the Twitter hashbang-Urls and they were processed correctly. The code I used is pretty straight forward. In index.php there is a forward...
<?php
if(isset($_GET['_escaped_fragment_'])) {
Header( "HTTP/1.1 301 Moved Permanently" );
header('Location: /hashbang'.$_GET['_escaped_fragment_']);
die();
}
?>
And in foo.php I just output Open Graph tags...
<!DOCTYPE HTML>
<html prefix="og: http://ogp.me/ns#">
<head>
<meta property="og:title" content="Foo" />
<meta property="og:url" content="http://jankrems.de/hashbang/foo.php" />
<meta property="og:description" content="The foo to go to" />
<meta property="og:image" content="http://tailsmagazines.files.wordpress.com/2009/04/kitten.jpg" />
</head>
</html>
Maybe I'm just blind and missing something obvious.

Resources