I'm developing a social app that requires some Open Graph actions.
I want the meta data tag for the title to be from my database because the name of my action title depends on the user choice.
Is it possible to get the title meta from database, rather than being hard coded? For instance:
<meta property="og:title" content="<?php echo $someTitle ?>" />
Of course it is possible – but how to you want to know what content to put out when?
When Facebook scrapes your URL, your site’s user is not involved. So that means you have to transfer some info via the query string or something; and that would make them different URLs, so you’ll end up with different OG objects as well.
Related
i am working for a php application using codeigniter framework. i have to create a facebook page share link. for that i am trying to set meta tags dynamically.
i have to set Title, Description and Image Url dynamically.
i am using following code to set meta tag in head section
<meta property="og:image" content="http://some path/11.jpg"/>
<meta property="og:image:secure_url" content="http://somepath/callHealthCondDesc?id=1" />
<meta property="og:title" content="TITLE" />
<meta property="og:description" content="DESCRIPTION" />
after that setting meta tag dynamically in ready section
$(this).ready(function() {
$('meta[name=og\\:title]').attr('content', 'new title');
$('meta[name=og\\:description]').attr('content', 'new description');
$('meta[name=og\\:image]').attr('content', 'http://new image url');
}
but it is not constructing the page dynamically with new parameter.
i have checked some similar post
but could not get the working solution for me.
i am not clear where i am doing mistake. please guide me for the issue
As i answer to this question even if it's not you exact case, you can't edit dynamically via js or other client site way the OG meta, facebook will use always the original html OG meta.
Case 1
If you are using php and you want make them dynamic you can opt for a solution similar to 2) where you change server side the OG meta when the page is loaded (there are different way i think, a parameter in the url can works if you have only few cases)
Case 2
You can try the Feed dialog share where you can choose the shared parameters.
You are no more linked to the OG meta, but you can anyway set them to use in case some user share the page in another way.
I've discovered whilst typing my question a small exchange on this at Adding a URL hash into meta data for Facebook and Twitter share cards which suggests that this may not be feasible but as things change over time I thought I'd seek guidance.
The scenario:
I have a URL http://example.com/ which includes appropriate Facebook meta in the header. I'm most interested in:
<meta property="og:image" content="whatever.jpg" />
At a later date I may add some additional info on the page and link to it with an anchor - e.g. http://example.com/#new and may want to display different meta for that anchor, e.g.
<meta property="og:image" content="whatever-another.jpg" />
My question is, is there any way to dynamically change the meta depending on whether the URL shared is the original URL or the URL with an anchor. The page could have multiple anchors.
My site uses Wordpress so I can use things like custom fields, etc if they are a possible manual solution but whatever, the ability to change the meta field based on the URL anchor is the goal.
Appreciated any guidance.
I am try to get for my joomla 2.5 website the feature of facebook "preview link". This feature should generate a preview when I enter a link in my article (just like facebook does in the status field). I only need this features for link to text/images not to video.
I found this link but I am having difficulties to understand how I am suppose to implementing it into a joomla website.
Thanks a lot for your help!
To dictate what is used for a Facebook link in your content, you need to make use of the Facebook OpenGraph meta tags.
Take a look at this section of the Facebook Developers site, mainly Section 3: Use proper Open Graph tags.
Link Here
The three you need for what you're after are:
<meta property="og:title" content="MyContentTitle" />
<meta property="og:description" content="Enter your snippet here." />
<meta property="og:image" content="http://myurl.com/images/logo-100x100.jpg " />
You can either statically set these for your website, or manipulate the template files for your articles, and echo out the article titles/images/snippets using PHP.
//EDIT//
After clarification from the comments, the easiest method would be to add tooltips using jQuery/jQuery UI:
jQuery UI Tooltips
You can make the tooltips as large as you like, so you could add a preview of the article that is leads to.
Of course, you'll have to make changes to your site template to add this, and also include jQuery UI/jQuery to your template header, if it's not there already.
In addition to that, you'll need to use PHP to echo the article title, description and image within the tooltip.
I've a site and it has a News webpage called something like www.website.com/news/detail/id/3. Now when I try to share this on any social media sites it is taking the title of www.website.com for any of the news details I share, i.e only one title of the website is being shown for any links. I want to see News detail page URL to be shared in a way that when a user clicks it it should directly goto that details page that is dynamically created on addition of every news in MySQL. I'm struggling to solve this and want anyone who has a clear idea on how to set the particular News or article to be shared using a url link of that news detail page on any of the social network sites. Eg.. as said above sppose I've a News Title lets say "Welcome to Daniweb, the website for every technology to technocrats" and its url is www.website.com/news/detail/id/4 When I share or post the above link it should show the news title as "Welcome to Deniweb, etc... followed by some part of description or image of that article. I hope you might have a clear idea about this. something we see on linkedin.com
How to change the id 4 to News_title in the url link and I'm using the Model, Views, Controller, then the url of a specific page I view must be of this kind eg. www.website.com/articles/welcome_to_dani_web_a_site_for_blah_blah_blah.... etc.
Where should I change the code to set the various titles for each webpages, that can be shared using a url link with the particular content of that webpage linked to that shared url. I've a common .../includes/header.php & ../includes/footer.php embedded in all the pages in ..views/scripts/xxxxxx.phtml pages How?
How to share the news using the url link that is dynamically created when someone posts an article. You may see in Linkedin.com of the articles being shared from some website, its image, Title, content is seen with url of particular webpage, Hope you have a clear idea of this kind and got me what I'm saying How?
This is how the code I've crafted and lost in it, not sure where I'm going wrong. Please
Help. Specific part of the code is shared as shown below for your reference, .../scripts/news/detail.phtml page is as follows:
<div class="newsviewwholepad">
<div class="leftcol">
<div class="textnews"><br/>
<div class="floatleft">
<h2><a><?echo $this->queryresult[0]['News_Title'];? ></a></h2>
<pa>By: <?echo $this->queryresult[0]['News_Editor'];?>,
Published: <?echo $this->queryresult[0]['Published_Date'];?></pa>
</div>
<div class="floatright">
<a style="color:#666;" href="http://www.addthis.com/bookmark.php?v=300" onmouseover="return addthis_open(this, '','[URL]', '[News_Title]')" onmouseout="addthis_close()" onclick="return addthis_sendto ()">Share</a>
Here I've used the addthis so as to share it using a button and it does not work, also when I share a complete url of the webpage on social sites it still does not work, HELP?
<p><? echo $this->queryresult[0]['News_Content'];?> </p>
</div>
</div>
</div>
Why don't you use the Open Graph tags http://ogp.me/ , that is the universal protocol for sharing web pages across sites like Facebook, LinkedIn and Twitter.
Just for your reference
<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>
This will share your article across social media as you wanted.
Although using Open Graph tags is a good idea if you want to target specifically sites like facebook, you can use other technologies to improve your actual situation in deeper way. Also, consider that Open Graph is/was based on RDFa.
For instance, you can set mod_rewrite to have meaningful urls. You can use, dublin core, microformats, RDFa or Schema.org to provide meaningul metadata on your pages that can be used by sites like facebook and the like or other systems like google.
I am developing pages in php dynamically i.e data gets filled up from mysql DB. how do i assign a proper meta data and description for these dynamic pages so that google recognises it properly.
What needs to be passed in page so that google takes description properly. when i search a page in google. it takes the data in page as description not description tag contents
<meta name="description" content="<?php echo $your_meta_description ?>" />
It depends on what you are using to build your site. Wordpress, for instance, doesn't come with meta description functionality by default. You would need to use a plugin.
Google will use your description only if it contains the keyword been searched for, and if it confirms that the meta description supplied accurately describes the content of the page.
This article might help: How to specify how your site looks in the search engines