PHP - Help With Facebook Like/share Buttons
I 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. Similar TutorialsCan 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? This topic has been moved to Other Libraries and Frameworks. http://www.phpfreaks.com/forums/index.php?topic=347238.0 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 :/ 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! 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 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 This topic has been moved to Miscellaneous. http://www.phpfreaks.com/forums/index.php?topic=349561.0 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.'" />';} ?> 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. 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 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 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 My setup: (everything on a local network) Web server: Ubuntu Server 8.10 -- Workgroup File server: Windows Server 2008 x64 -- domain Test server: Win 2000 running WAMP -- domain I'm trying to run the code snippet below. $file is a file on the File server above. It definitely exists. Running the code below on the Test server works perfectly. But the file cannot be found when running from the Web server. $file = '//server/share/file.txt'; if (file_exists($file)) echo 'yay!'; else echo 'error'; What with the safe mode considerations, I've also tried to add: ini_set('safe_mode', 'Off'); to no effect. And since file, and fopen similarly not work, I'm pretty sure it's not that either. The File & Test servers are on the same Windows domain, but that's definitely not the reason. I tried the code on a file on a Linux computer in the Workgroup (where the Web server is) with the same results: Test server works, Web server does not. Please advise; I'm really lost. 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. Hi Guys, I am using the PHP Facebook code with my app; <?php $app_id = ""; $app_secret = ""; $my_url = ""; session_start(); $code = $_REQUEST["code"]; if(empty($code)) { $_SESSION['state'] = md5(uniqid(rand(), TRUE)); //CSRF protection $dialog_url = "https://www.facebook.com/dialog/oauth?client_id=" . $app_id . "&redirect_uri=" . urlencode($my_url) . "&state=" . $_SESSION['state']; echo("<script> top.location.href='" . $dialog_url . "'</script>"); } if($_REQUEST['state'] == $_SESSION['state']) { $token_url = "https://graph.facebook.com/oauth/access_token?" . "client_id=" . $app_id . "&redirect_uri=" . urlencode($my_url) . "&client_secret=" . $app_secret . "&code=" . $code; $response = @file_get_contents($token_url); $params = "user_questions"; parse_str($response, $params); $graph_url = "https://graph.facebook.com/me?access_token=" . $params['access_token']; $user = json_decode(file_get_contents($graph_url)); echo("Hello " . $user->name); } else { echo("The state does not match. You may be a victim of CSRF."); } ?>() However I am having issues with the permissions, I can only ever get it to ask for "Yout basic info" when it needs to ask for more than that. Any ideas why? Cheers in advance. On Facebook, when you click on "view friends" on one of your friends' profile, a window pops up. Is that made with PHP? Or is it flash or something? In case it's PHP, what would you use to make something like that? Thank you in advance! At work I wrote many classes/function that are hundreds of lines of code. This code rarely changes, but it does happen. Some of this code is also used in all 4 of the sites. Problem right now is I have "4 sites" with duplicate code on them (copy/pasted). All on a single server running IIS. How can set this up so all 4 sites "share" the same PHP code? My temporary "dirty" fix to this has been to: Setup a 5th site in IIS. Setup a firewall rule to block any access to it, then rename all my PHP files to ".txt" files then simple do "require "somePHPcode.txt" (this way IIS wont "run them" before sending them). This works, but its not very elegant. Got a better method? Hi all, I am a beginner for PHP. I created a site & now I want to add a wall post to my Facebook Page. This post should be posted via PHP when I add a post to my site, without manually adding that on Facebook Page. I referred Facebook Developer documentations, but those are really mess for me. I really don't want this to do with php-sdk or any other. I want to do this manually. Thanks Hi there! First, i must say that i have no php knowledge, maybe a 1% Here is what i want to do: I have wordpress, with a plugin called Facebook connect, it has a cool feature where you can invite your facebook friends, it looks like this: http://dailyerz.com/login/?fbconnect_action=invite And i am also using cubepoints, a plugin that rewards users with points. I want to reward users for every user they invite. From the cube points docs http://techcube.net/docs/1.3/docs.html i got this: Quote The following code will add 10 points to the current logged in user. If no user is logged in, no points will be added. You may input negative number to subtract points. <php if( function_exists('cp_alterPoints') && is_user_logged_in() ){ cp_alterPoints(cp_currentUser(), 10); } ?> and the invite.php of facebook connect looks like this: <?php get_header(); $fb_user = fb_get_loggedin_user(); ?> <div style="padding:20px;" > <?php if(FBCONNECT_CANVAS=="web") : ?> <fb:serverfbml style="width: 100%;"> <script type="text/fbml"> <fb:fbml> <?php endif; ?> <fb:request-form action="<?php echo get_option('siteurl'); ?>" method="GET" invite="true" type="<?php echo get_option('blogname');?>" content="<?php echo get_option('blogname')." : ".get_option('blogdescription'); ?> <fb:req-choice url='<?php echo get_option('siteurl'); ?>' label='<?php _e('Become a Member!', 'fbconnect') ?>' /> " > <fb:multi-friend-selector rows="5" email_invite="false" cols="3" showborder="false" actiontext="<?php _e('Invite your friends to Dailyerz.', 'fbconnect') ?>"> </fb:request-form> <?php if(FBCONNECT_CANVAS=="web") : ?> </fb:fbml> </script> </fb:serverfbml> <?php endif; ?> </div> <?php get_footer(); ?> Any idea on how to make this work? Do i have to create a Facebook App? Thanks! |