I want to share title , image and description on facebook without javascript just by passing these to share.php of facebook.
I got some code on this site in question Open source alternative to AddThis AddToAny, ShareThis etcfor Social Bookmarking
and I have read the question how to pass custom parameter in facebook sharer link
Now I want to combine both questions. Can I pass Image, title and description simply in the facebook share.php url
like:
<a class="scmFacebook" href='http://www.facebook.com/sharer.php?s=100&p[title]=<?php echo $title;?>&p[summary]=<?php echo $summary;?>&p[url]=<?php echo $url; ?>&&p[images][0]=<?php echo $image;?>'>Facebook</a>
OR
If I am wrong then please show me the right destination.
According to the facebook developers (bug):
The sharer will no longer accept custom parameters and facebook will pull the information that is being displayed in the preview the same way that it would appear on facebook as a post from the url OG meta tags.
Either you use the Share Button - requires Javascript SDK
Or, use the latest Share Dialog - requires just an app id. It has a direct url direction method for invoking the share dialog:
https://www.facebook.com/dialog/share?
app_id={app-id}
&display=popup
&href={link-to-share}
&redirect_uri={redirect-uri}
<head>
<meta property="og:title" content="Title" />
<meta property="og:image" content="image_link" />
<meta property="og:url" content="https://www.google.com/" />
<meta property="og:description" content="Description" />
<meta property="og:site_name" content="Google" />
</head>
<body>
Facebook
</body>
Use meta property to use title description and image and link sharer.php to share
Related
Whenever I post a link of a post from my blog on Facebook, Facebook shows the wrong author.
Screenshot:
The meta tag in my header.php has another author in it.
<meta name="author" content="MYAUTHORNAME">
I searched the web and tried to add this:
<meta property="article:author" content="https://www.facebook.com/MYSITE" />
<meta property="article:publisher" content="https://www.facebook.com/MYSITE" />
But still no effect. I don't know where the author tag on Facebook is coming from.
Check if you dont have a publisher meta:
<meta property="article:author" content="https://www.facebook.com/fareedzakaria" />
<meta property="article:publisher" content="https://www.facebook.com/cnn" />
Source: https://developers.facebook.com/docs/sharing/best-practices#crawl
Also check if your code is valid using this:
https://developers.facebook.com/tools/debug/og/object/ insert the url and press "fetch new scrape information" and see if that fixes it.
I'm trying to integrate the Facebook share feature in my application but whenever I click on the share button , Facebook will pull up meta data from the head and instead of showing the current title and URL it returns my login page URL and login page title , I have tried this
Facebook share button is sharing my login page instead of current page URL, title, etc
But according to Facebook the Feed button was dereciated and replaced with the share button
The code below is included in every page of my app
<meta property="og:title" content="<?php echo $title ?>"/>
<meta property="og:type" content="Type of content"/>
<meta property="og:url" content="<?php echo current_url() ; ?>"/>
<meta property="og:site_name" content="My site name"/>
<meta property="og:description" content="<?php echo $description ; ?>"/>
Ok, i think it's got to do something with the Facebook scraper. As mentioned in the docs here
In some cases you may want to serve a different version of a page to
our scraper (containing more Open Graph metadata) than you do to
people who are viewing the page. In this case you can target the
browser agent used by the scraper:
"facebookexternalhit/1.1 (+http://www.facebook.com/externalhit_uatext.php)"
So I think in the php file of your website you can put in a check for the scraper like this:
if (strstr( $_SERVER['HTTP_USER_AGENT'], 'facebookexternalhit') {
// Show more open graph metadata here
} else {
// Your login page
}
To make the scraper cache your data, use the debugger tool.
I have an application on laravel and i am using AddThis (https://www.addthis.com/) for my website.
Everything is fine when i try to share the homepage, but i keep getting this "Whoops! There was an error." when i try to share any non-index pages.
I am using templating for the mata-data on the various pages
in my base.blade.php i have
<meta property="og:site_name" content="ALLMENZ" />
<meta property="og:url" content="mycontent" />
<meta property="fb:app_id" content="" /> <!-- for facebook-insights-->
<meta property="og:title" content="{{{$meta_title}}}" />
<meta property="og:description" content="{{{$meta_description}}}" />
<meta property="og:image" content="{{{$meta_photo}}}" />
and in the non-index page i have
<?php View::share('meta_title', 'user timeline'); ?>
<?php View::share('meta_description', 'this is the user timeline page'); ?>
<?php View::share('meta_photo', ''); ?>
Anyone has any idea what is happening here? Thanks in advance (=
You should generate the tag's content dynamically, for example, to generate the current url with http/https use following in your og:url:
<meta property="og:url" content="{{ Request::url() }}" />
The Request::url() will generate the current url for the page you are on. Also, don't leave any blank content in any meta tag. Then debug the url's using Debugger Tool.
What Worked For Me
If you happen to be trying to use AddThis with UTM codes or other querystring variables, here's what finally worked for me.
As per Sol, use OpenGraph meta tags but then use the FB Debugger to verify that Facebook cache has been refreshed and got all the proper meta tags in the page header correctly, then verify that there are no querystring UTMs/variables your AddThis sharing link to facebook. For my purposes, Index.html couldn't include any querystring variables or AddThis passed the URL incorrectly to Facebook. The only way that worked for me looks like this:
<a href="http://api.addthis.com/oexchange/0.8/forward/facebook/offer?pco=tbx32nj-1.0&url=https%3A%2F%2Fwww.example.com%2Findex.html" target="_blank" ><img src="http://cache.addthiscdn.com/icons/v1/thumbs/32x32/facebook.png" border="0" alt="Facebook" /></a>
What Failed For Me
When trying to use the below AddThis "data_track_addressbar" and "addthis_widget.js" modules for sharing, Facebook completely fail to pull the new OpenGraph Meta Tags.
<script type="text/javascript">var addthis_config = {"data_track_addressbar":false};</script>
<script type="text/javascript" src="//s7.addthis.com/js/300/addthis_widget.js"></script>
I have the following url to a file on my website:
http://www.foo.com/download/1
This downloads the file with the force_download function, using the download helper.
I've been requested to provide like buttons for these files which are displayed in a html table on one of the site's pages.
So, using facebook like button tool I've created the following button:
<div class="fb-like" data-href="http://www.foo.com/download/1" data-send="false" data-width="450" data-show-faces="false"></div>
However, because this is a direct link to the file, the correct open graph metadata is not being received e.g. the description is: "%PDF-1.3 %�ãÏÓ 1041 0 obj.."
So my question is how do I provide the open graph metadata for links to my downloads? For example:
<meta property="og:type" content="website" />
<meta property="og:url" content="http://foo.com/download/1" />
<meta property="og:title" content="Download 1" />
<meta property="og:image" content="bar.png" />
<meta property="og:description" content="File description" />
For the url that where you download the file itself you can't, since it's (probably) not an html page and even if it is, you wouldn't want to change the content of the file with your own metadata.
What you can try is use some kind of redirection on the URL used by both the clients downloading the file and the crawlers of facebook, and of course you will need an url for the real download too.
On your view sent for like and the users:
<!-- meta tags -->
<meta property="og:type" content="website" />
<meta property="og:url" content="http://foo.com/download/1" />
<!-- .... -->
<body>
<script>
// imaginary real download url url
window.location = '<?php site_url('download/real_download/'.$download_id);?>';
</script>
</body>
Facebook also doesn't seem to understand refresh meta tags, so you can write and avoid javascript usage:
<meta http-equiv="refresh" content="1;URL='<?php site_url('...')?>'">
Disclaimer: I didn't find any documentation from facebook that describe what their crawlers understand so there's no guarantee that any of these will keep working. I myself using a javascript solution for like a year now in a similar situation.
How can I change the content of my facebook share option? my web app is written on PHP with Zend Framework. I want to change the content of the facebook share option instead of the description that was already been in the website.
If you use fb social plugin, it reads the open graph tags.
<meta property="og:title" content="title" />
<meta property="og:description" content="description" />
<meta property="og:image" content="thumbnail_image" />
You can set those in zend by using in controller
$this->view->headMeta()->setProperty('og:description','asdasdasd');
$this->view->headMeta()->setProperty('og:title',"title here");
$this->view->headMeta()->setProperty('og:image',"url");
if you dont want to use that open graph tags,
Creating Your Own Share URL
https://www.facebook.com/sharer/sharer.php?s=100&p[title]=titlehere&p[url]=http%3A%2F%2Fwww.yoururlhere.com&p[summary]=yours description
Open that URL in a browser, when user click share icon/link.
Btw, share is deprecated.
FYI: https://developers.facebook.com/docs/share/
FB Share description:
You can control the exact title, description, and thumbnail that Facebook Share uses by adding the following meta tags to the element in your page:
<meta property="og:title" content="title" />
<meta property="og:description" content="description" />
<meta property="og:image" content="thumbnail_image" />
please read more here:
regards.