yasirmehmood123 Posted October 14, 2014 Share Posted October 14, 2014 Hi, I have a page whihc gets Daily motion URL from another page and also location of Image. I have Face book share button on this page and want to show my inage while trying to share on FB. unfortunatley face book picks something wrong , and I use Open Graph Debug library then temporarily this picture issue gets resolved but it re-occures again if another URL is selected for sharing purpose. Code written in header of my page: <meta property="og:title" content="Greate Web SIte"/><meta property ="og:url" content="http://www.MySIte.com/ShowMovie.php"/><meta property ="og:type" content="website"/><meta property="og:image:width" content="200" /><meta property="og:image:height" content="200" /><?php $selectedImage=$_GET['selectedImg']; // this param is passed from qry string whihc is sent by a previos page, I want to change this param every time parent page sends a request of new image. $ImageAddress='http://www.mySIte.com/'.$selectedImage; //creating URL of image , if i paste this URL in browser , image is fetched successfully. echo '<meta property="og:image" content="'.$ImageAddress.'"/>';?> <meta property="og:site_name" content="my Heading"/><meta property="og:description" content="Bla Bla bla."/> Following is the java script that I have pasted under body tag: <div id="fb-root"></div><script>(function(d, s, id) { var js, fjs = d.getElementsByTagName(s)[0]; if (d.getElementById(id)) return; js = d.createElement(s); js.id = id; js.src = "//connect.facebook.net/en_US/sdk.js#xfbml=1&version=v2.0"; fjs.parentNode.insertBefore(js, fjs);}(document, 'script', 'facebook-jssdk'));</script>following is button for FB share: echo '<div class="fb-post" data-href="'.$pageURL.'" data-width="500"></div>'; // URL that is passed as qry stirng are passed here. kindly do let me know that how can I display the exact image on every attelp to share something. Quote Link to comment Share on other sites More sharing options...
QuickOldCar Posted October 14, 2014 Share Posted October 14, 2014 $selectedImage=$_GET['selectedImg']; // this param is passed from qry string whihc is sent by a previos page, I want to change this param every time parent page sends a request of new image. $ImageAddress='http://www.mySIte.com/'.$selectedImage; //creating URL of image , if i paste this URL in browser , image is fetched successfully. You query mysql with the page id or slug from your databse (something unique), then should be able to get all the info you need and populate the opengraph data. Don't rely on passing GET requests from previous pages or ones that could possibly be empty or wrong. Quote Link to comment Share on other sites More sharing options...
yasirmehmood123 Posted October 15, 2014 Author Share Posted October 15, 2014 I have also tried the same as suggested that Values should be picked from database rather than Qrystring but it gives the same result. I want to get latest image while sharing through FB share button but I dont know how FB picks another image randomly. Quote Link to comment Share on other sites More sharing options...
QuickOldCar Posted October 15, 2014 Share Posted October 15, 2014 If you don't cache your pages, then is facebook caching results. Is a debugger tool there. http://developers.facebook.com/tools/debug https://developers.facebook.com/docs/technical-guides/opengraph/defining-an-object/#update you can post to graph.facebook.com with 'scrape=true' and it will re-fetch the content Quote Link to comment Share on other sites More sharing options...
yasirmehmood123 Posted October 15, 2014 Author Share Posted October 15, 2014 can you please provide me the sample code for using the Open graph API ? Quote Link to comment Share on other sites More sharing options...
yasirmehmood123 Posted October 16, 2014 Author Share Posted October 16, 2014 Any one could help me, I just want to select the latest image while sharing for face book from my website. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.