PHP - How Do I Add A Facebook Share Button?
Can somebody please explain how to properly add a Facebook Share button to my site?
It's not simply a matter of generating the button and pasting the code into my pages; in order to ensure that the right information is shared, I also have to add Open Graph metatags.
But the thing that's confusing me is that one of the required Open Graph metatags is this:
<meta property="fb:app_id" content="APP_ID_NUMBER" />Questions 1) Does this mean that I have to register as an app builder before I can add the Share button? If so, why doesn't Facebook say so on the Share button page? 2) When generating the Share button, I am asked for the "URL to share". Does this mean that I have to generate a different Share button for each page? Surely not. 3) I use ShareThis at the moment. Does ShareThis work with Facebook Insights? Similar TutorialsI have placed the Facebook LIKE/SHARE buttons on a website using the following:
<div class="fb-like" data-href="http://mysite.com" data-layout="standard" data-action="like" data-show-faces="false" data-share="true" data-width="280px"></div>the LIKE button works fine. the SHARE button works but i cannot seem to customize and of the values such as which image to include. i have the following in my HEAD section but it does nothing. do i need to create an APP and reference the ID? any help is much appreciated <meta property="og:type" content="website" /> <meta property="og:title" content="Can tea make for a happy marriage" /> <meta property="og:url" content="http://mysite.com/index.php" /> <meta property="og:image" content="http://mysite.com/pics/gallery/2.jpg" /> Edited by BuildMyWeb, 28 September 2014 - 05:18 PM. This topic has been moved to Other Libraries and Frameworks. http://www.phpfreaks.com/forums/index.php?topic=347238.0 Hi all, I'm not great with PHP and I have this one problem that I hope you can help with. I have a script that generates an URL. The output string is $shorturl and displays properly when I echo it using Code: [Select] <?php echo '$shorturl' ?>. However, when I try the following script for a Facebook share button Code: [Select] <fb:share-button> <a name="fb_share" type="button" share_url="<?php echo '$shorturl' ?>" href="http://www.facebook.com/sharer.php" layout="button_count">Share</a><script src="http://static.ak.fbcdn.net/connect.php/js/FB.Share" type="text/javascript"></script> </fb:share-button> The resulting URL it produces is: http://</?php+echo+%27http%3A%2F%2Fshelb... Any idea's? Thank you! after spending many hours thinking this through and not really getting anywhere, trying to figure out how this site works, so that i can replicate it and make a single image from multiple images that are positioned overlaying with css positioning
the site in question is: http://www.dahippo.c...6360ZZ0ZZ0ZZ0ZZ
it is a type of calculator for an online game, the part that interests me is the image of the ship that is built up from many images
is also uses a php script to place all these images into on image file outputted to html, this is what interests me and i am trying to recreate, like he http://www.dahippo.c...6360ZZ0ZZ0ZZ0ZZ
here is the outputted html:
<html> <head> <meta name="viewport" content="width=device-width, minimum-scale=0.1"> <title>get.php (635x317)</title> </head> <body style="margin: 0px;"> <img style="-webkit-user-select: none; cursor: -webkit-zoom-in;" src="http://www.dahippo.com/bp/ship/get.php?image=4J01Q180O0K0E013C3A3C3A3636360ZZ0ZZ0ZZ0ZZ" width="408" height="204"> </body> </html>what php code used in the get.php script make all these images with css positioning into 1 image? i have asked the site owner, and got no reply :/ I have been trying to replicate the facebook "share" functionality , well actually i was in need of this functionality even before i knew that fb already had it.. I learnt a few things that this can be achieved by using the "Curl" and I also hear that this setting may have been switched in some servers so if anyone can refer me to other options that would always fetch me the - Title- Description- Images for sure I' d be thankful Regards I am trying to implement the method described in this post: http://www.addthis.com/forum/viewtopic.php?f=4&t=24637 to get my Addthis button to act the way I need it to. I have posted on the site, but have gotten no response. I cannot get it to work. Can anybody have a look at the code below and see if they can help? Thanks The PHP I need to modify is: <?php defined('C5_EXECUTE') or die(_("Access Denied.")); $html = Loader::helper('html'); $uh = Loader::helper('concrete/urls'); $bt = BlockType::getByHandle('news_list'); global $c; $rss_address = $controller->getRssUrl().'?ctID='.$ctID.'&bID='.$bID ; if (isset($_GET['pageno'])) { $pageno = $_GET['pageno']; } else { $pageno = 1; } // if ?> <div class="newsflash1"> <div class="headtitle1"> <?php echo $rssTitle ?> </div> <?php if (!function_exists('newslistParse')) { function newslistParse($url,$thumbnail,$thumbwidth,$time,$content,$title,$date){ //###################################################################################// //here we lay out they way the page looks, html with all our vars fed to it // //this is the content that displays. it is recommended not to edit anything beyond // //the content parse. Feel free to structure and re-arrange any element and adjust // //CSS as desired. // // available vars: $url,$thumbnail,$thumbwidth,$time,$content,$title,$date // //###################################################################################// ?> <div class="newsflashcontain1"> <div class="title1"><h3><?php echo $title; ?></h3> </div> <div class="time1"> <?php echo $date; ?></div> <div class="description1"><?php echo $content;?></div> <div class="addthis_toolbox addthis_default_style"> <a class="addthis_button" addthis:title="Title goes here" addthis:description="Check their site!" addthis:url="http://www.davidcunniffe.com/test3/index.php?cID=69" href="http://www.addthis.com/bookmark.php?v=250&username=dcunniffe"/> <a class="addthis_button_facebook"></a> <a class="addthis_button_twitter"></a> <a class="addthis_button_favorites"></a> <a class="addthis_button_email"></a> <a class="addthis_button_print"></a> <a class="addthis_button_facebook_like"></a> <script type="text/javascript" src="http://s7.addthis.com/js/250/addthis_widget.js#username=dcunniffe"></script> </div> </div> <?php //#####################################################################################// //this is the end of the recommended content area. please do not edit below this line // //#####################################################################################// } } $db = Loader::db(); //go grab the posts, check if they are current, return only current posts Loader::model('newzy','simplenews'); $news = NewsCheck::getCurrentBlocks($ctID,$ordering); //count the number of current posts returned $pcount = count($news); //if no events are returned, then we display a user defined message if($pcount==0){ echo $nonelistmsg; } //now calc the last page $lastpage = ceil($pcount/$num); //set the current page min max keys -1 as array key's start @ 0 $sKey = $num * ($pageno-1) ; $eKey = ($num * ($pageno-1)) + ($num-1) ; //take each current post and treat it like a query, for each one do X foreach($news as $key => $row){ //check for external URL, if none, rout to parent page if(!empty($row['urlLink'])){ $url = $row['urlLink']; }else{ $url = $controller->grabURL($row['cParentID']); } //check if thumbnail is there, if so get it, if not, null if($row['graphic']>0){ $thumbnail = $controller->getThumbnail($row['graphic']); }else{ $thumbnail = NULL; } //set vars $time = $controller->replaceTimeString($row['nbID']); $date = date('l, jS F, Y'); $title = $row['title']; $content = $controller->translateFrom($row['content']); //$content = $controller->translateFrom($row['content']); //if truncation is enabled if($truncateSummaries == 1){ if (strlen($content) >= $truncateChars){ //truncate to suplied truncation value //$content = substr($content,0,$truncateChars).'.....'; $content = wordwrap($content, $truncateChars); $content = substr($content, 0, strpos($content, "\n")).'.....'; } } //check if paging is enabled if($isPaged){ //check to make sure the array key is within the range if($key >= $sKey && $key <= $eKey){ newslistParse($url,$thumbnail,$thumbwidth,$time,$content,$title,$date); } //if paging is not selected, use number of items designated in the list block }else{ $i += 1; newslistParse($url,$thumbnail,$thumbwidth,$time,$content,$title,$date); //once we reach the set number stop the script if($i >= $num){ break; } } } ?> </div> <?php //is iCal feed option is sellected, show it if($showfeed==1){ ?> <div class="rssfeed1"> <img src="<?php echo $uh->getBlockTypeAssetsURL($bt, 'rss.png');?>" width="14" height="14" alt="rss feed" /> <a href="<?php echo $rss_address ; ?>" id="getFeed">Get Feed</a> <link href="<?php echo $controller->getRssUrl();?>" rel="alternate" type="application/rss+xml" title="<?php echo t('RSS');?>" /> </div> <?php } //$c = Page::getCurrentPage(); $link = Loader::helper('navigation')->getLinkToCollection($c); $link = $controller->URLfix($link); //if pagination is set, if it is needed, show it if($isPaged==1){ if ($pcount > $num) { echo '<div id="pagination">'; if ($pageno == 1) { echo " FIRST PREV "; } else { echo '<a href="'.$link.'pageno=1">FIRST </a>'; $prevpage = $pageno-1; echo '<a href="'.$link.'pageno='.$prevpage.'"> PREV</a>'; } // if echo ' ( Page '.$pageno.' of '.$lastpage.' ) '; if ($pageno == $lastpage) { echo " NEXT LAST "; } else { $nextpage = $pageno+1; echo '<a href="'.$link.'pageno='.$nextpage.'">NEXT </a>'; echo '<a href="'.$link.' pageno='.$lastpage.'"> LAST</a>'; } // if echo '</div>'; } } if (isset($bID)) { echo '<input type="hidden" name="bID" value="'.$bID.'" />';} ?> Hi every one I want to share a page content(or an article) into my facebook page via php . How should I do that ? Thanks 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.co...howMovie.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 sha 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. Hello. I have a facebook like button. It is wrapped in an iFrame. What I would like to create is a Form that when the user clicks the submit button the action is to process the Facebook like button. So pressing my button presses the facebook like button as well. Why? Because I would like to keep track of users that click the like button. This is an example of the like button. <iframe src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fwww.likethis.com&send=false&layout=standard&width=450&show_faces=true&action=like&colorscheme=light&font&height=80" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:450px; height:80px;" allowTransparency="true"></iframe> I got this piece of code:
<div class="tbl tbl-facebook" id="<? echo $site->facebook;?>"> Hello I am using joomla with sobi2. im working in the sobi2 details template. I am having some difficulties with the like button. maybe i'm going about it all wrong but ill show you what i got and hopefully you can lend me some advise. This works <?php echo '<p><iframe src="http://www.facebook.com/plugins/like.php?href='; ?> <?php echo 'www.google.com'; ?> <?php echo '&layout=standard&show_faces=false&width=450&action=like&colorscheme=light&height=35" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:450px; height:35px;" allowTransparency="true"></iframe></p>'; ?> output ---- (working like button) ---- this works <?php $testv='www.google.com' ?> <?php echo $testv ?> <?php echo '<p><iframe src="http://www.facebook.com/plugins/like.php?href='; ?> <?php echo $testv; ?> <?php echo '&layout=standard&show_faces=false&width=450&action=like&colorscheme=light&height=35" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:450px; height:35px;" allowTransparency="true"></iframe></p>'; ?> output ------ www.google.com (working like button) ------- This doesn't work <?php $testv=$fieldsFormatted['field_street']; ?> <?php echo $testv ?> <?php echo '<p><iframe src="http://www.facebook.com/plugins/like.php?href='; ?> <?php echo $testv; ?> <?php echo '&layout=standard&show_faces=false&width=450&action=like&colorscheme=light&height=35" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:450px; height:35px;" allowTransparency="true"></iframe></p>'; ?> output ------- www.google.com (not working like button) -------- facebook gives me an error "The page at http://<span%20%20id=/ could not be reached." This topic has been moved to Other Libraries and Frameworks. http://www.phpfreaks.com/forums/index.php?topic=356192.0 Hello! I need a little help here please! This is the end of the code on a page. It shows a pic with a gallery assigned to it. I want to attach a facebook like button to the pic, not the gallery. Since its a dynamic page I modified the like button code. But for some reason I just cant fit it in. Im kind of a novice and i didnt write this code on my own:) Oh and yes I coud stick the code right into the webpage, but its a generic site so i cant do it on every single page. So how do you say in "PHP" to put "this" on the page in "this" div tag, and where do you put it in to work properly? .... $res.="<div class=\"works\"> <div class=\"worksleft\"> <div class=\"worksimg\"> <img src=\"<resource>".$img["name"]."</resource>\" width=\"".$img["x"]."\" height=\"".$img["y"]."\" alt=\"".$mass["xtitle"]."\" title=\"".$mass["xtitle"]."\" > </div> <div class=\"workstxt\">".$tit."</div> </div> <div class=\"worksright\"> ".$gal." </div> <div class=\"clear\"></div> ".$desc." </div>"; } $result[0]["head"]=""; $result[0]["body"]=$res; return($result); } .... and this is the code i have to put in: <iframe src="http://www.facebook.com/plugins/like.php?href=<?php echo "http://" . $_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI']; ?>&layout=button_count&show_faces=false&width=450&action=like&font&colorscheme=dark&height=21" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:450px; height:21px;" allowTransparency="true"></iframe> thanks very much in advance! I am trying to allow a user to proceed to another page but only after a user has clicked a Facebook like button and a check has been done to check if the currently logged in user has liked the specific Facebook Page. How can I go about this? Thanks in advance This topic has been moved to Other Libraries and Frameworks. http://www.phpfreaks.com/forums/index.php?topic=319295.0 This topic has been moved to Miscellaneous. http://www.phpfreaks.com/forums/index.php?topic=349561.0 I'm wondering if anyone can help me find/create a script which allows a preview of a link to be generated? Basically I need a user to be able to simply enter a url and click submit and then a preview of that link will be shown in the form of some text and an image. Very similar to what Facebook does when a user shares a link. I think they use the description tag of the site in general. Can anyone point me in the right direction in doing this? I need to be able to do it in php/javascript alone without the use of jquery or plugins. Dear Friends,
I have 3 different Applications under the same server. Please, could you help me to share info between them?
App1 is a "User Admin Application". Here the user should do the login. After the login, the User should be able to open App2 or/and App3 Hi,
I've added social sharing icons to every article on the homepage. Now they just share the page itself - the idea is to share that (wordpress) post/article. I've succeeded to do so with facebook likes on the English version with adding
<div class="fb-like" data-href="<?php the_permalink(); ?>"Now I want to do the same with these 3 share icons: <div class="social-content"><?php if (ICL_LANGUAGE_CODE=='zh-hans'): ?><div class="bshare-custom"><div class="bsPromo bsPromo2"></div><a title="分享到微信" class="bshare-weixin" href="javascript:void(0);"></a><a title="分享到新浪微博" class="bshare-sinaminiblog" href="javascript:void(0);"></a><a title="分享到QQ空间" class="bshare-qzone"></a><a title="更多平台" class="bshare-more bshare-more-icon more-style-addthis"></a><span class="BSHARE_COUNT bshare-share-count" style="float: none;">19.5K</span></div><?php endif; ?></div>Can this be done by adding PHP? I'm not sure where I would have to add this... Thanks Attached Files csr1.jpg 38.34KB 0 downloads I need to know if this is even possible. I have found conflicting information on this online. Anyway, here is what I want to do. I have two websites that reside on the same dedicated server. Both have different IP's. www.mywebsite1.com and www.mywebsite2.com. I need a user that logs in at www.mywebsite1.com to be able to pass the $_SESSION from www.mywebsite1.com to www.mywebsite2.com. Any help on this would be cool. Thanks in advance. Ryan |