The Facebook debugger does not parse the URL correctly. Parses http://url.com instead of http://url.com?param=value

I am trying to integrate opengraph on this website http://www.lsenow.com .

The person who wrote the topic used hard-coded mysql instead of the functions already provided by WordPress to retrieve data from the database. I do not know how relevant this is. I just did not see it, especially since it is not necessary.

I get this message when setting this URL (http://www.lsenow.com/?event=campus-tours-2) through the debugger:

The object at the URL "http://www.lsenow.com/" of the type "event" is invalid because the set value "for the property" og: image: url "may not be parsed as the type 'url'.

The facebook debugger gives me this regarding the url:

Scrape Information Response Code‎: 200 Fetched URL‎: http://www.lsenow.com/?event=campus-tours-2 Canonical URL‎: http://www.lsenow.com/ Redirect Path Original‎: http://www.lsenow.com/?event=campus-tours-2 301‎: http://www.lsenow.com/ 

I tried many things, I tried:

  • <meta property = "og: url" content = "<? php $ url =" http: // ". $ _ SERVER ['HTTP_HOST']. $ _ SERVER ['REQUEST_URI']; echo $ url ;?>" / ">
  • <meta property = "og: url" content = "<? php the_permalink ()?>
  • Adding <link rel = "canonical" href = "<? Php $ url =" http: // ". $ _ SERVER ['HTTP_HOST']. $ _ SERVER ['REQUEST_URI']; echo $ url ;?>" / ">
  • <meta property = "og: url" content = "http://www.lsenow.com/?event= <? php echo $ _GET ['event'] ;?>" / ">

Does anyone have a solution to this problem. I feel like adding code.

here is what i have:

 <!-------------------------- Open Graph ----------------------------> <link rel="canonical" href="<?php $url="http://".$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']; echo $url; ?>"/> <meta property="og:url" content="http://www.lsenow.com/?event=<?php echo $_GET['event'];?>" /> <meta property="og:title" content="<?php the_title(); ?>" /> <meta property="og:type" content="events"/> <meta property="og:image" content="http://placehold.it/300x300"/> <meta property="og:site_name" content="<?php bloginfo('name');?>"/> <meta property="og:description" content="<?php the_excerpt();?>"/> <meta property="fb:app_id" content="151709234971178" /> <!--------------------------End of Open Graph ----------------------------> 
+4
source share
1 answer

Facebook doesn't seem to like your placehold.it tag in the og:image tag. Since your URL contains a query string, Facebook redirects your primary URL.

Try replacing this with a static image from your site and see if it will be parsed.

You can also take a look at your .htaccess file and your code to see if there is anything there that can redirect the Facebook scraper.

+1
source

Source: https://habr.com/ru/post/1437554/


All Articles