PHP - Facebook Like Button Built With Php
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." Similar TutorialsHello. 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;?>"> 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? 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 Hi everyone. Good day for coding? I created this tiny script just for self-learning purposes but I'd like to improve it. Here is the script: Code: [Select] <?php include_once 'dbinfo.php'; if(isset($_POST['submit'])) { $label = $_POST['label']; $stm = $connect->prepare("INSERT INTO words(word) VALUES (?)");//$stm = $connect->prepare("INSERT INTO words VALUES (?,?)"); $stm->bind_param('s', $label);//$stm->bind_param('ss', $label, $user);http://php.net/manual/en/mysqli-stmt.bind-param.php $stm->execute(); printf("%d Label inserted.\n", $stmt->affected_rows); $stm->close(); $connect->close(); } ?> <form action="" name="submit_label" method="POST"> <p>Submit a Label:<input type="text" name="label" value=""></p> <input name="submit" type="submit" value="Submit label"> <p></p> <a href="wordlist.php" >The List of labels</a> </form> <?php if ($stm = $connect->prepare("SELECT word, label_id FROM words ORDER BY label_id")){ $stm->execute(); $stm->bind_result($labelcol, $labelcol2); while($stm->fetch()){ printf("%s %s</br>", $labelcol, $labelcol2); } $stm->close(); } $connect->close(); ?>It submits words and insert them in a table called words. It also outputs the table content, the submitted words. An image of a database structure is attached to this post. What I'd like to do is to count the how many times the same words are repeatedly submitted and output the the repeated word next to the number of times it is repeated. For example: user 1 submitted 'awesome' 3 times so it shows awesome (3) user2 submitted 'bad' 45 times so it shows bad (45).... and so on I'm guessing that I should use arrays and and built in functions and things like that but my question which functions should I use to get started or just give me some hint how to use arrays in this case. Thank you very much in advance. [attachment deleted by admin] I wonder if is out there function in php that is doin this . function like strpos that is does not notice from CAPITAL words to small words. function like strpos that does finds all matchs and not only 1. function like strpos that is search inside connected words like "strposfunction" so if i search "function" it will find it. thanks , Mor. Hi I'm new. These are some of the example strings I'm dealing with "update online SJ" "Change account GBBCDL" "CRM L" I was wondering if there is a built-in function or function(s) that could help me strip all the CAPS from the right of each string til it finds the first space. I'm not worried about those and would look much nicer to just display everything without that. Thanks from Jennifer is there a way of calling this function but just returning the classes you've loaded and not already built in classes with php please? Code: [Select] Array ( [0] => stdClass [1] => Exception [2] => ErrorException [3] => COMPersistHelper [4] => com_exception [5] => com_safearray_proxy [6] => variant [7] => com [8] => dotnet [9] => DateTime [10] => DateTimeZone [11] => ReflectionException [12] => Reflection [13] => ReflectionFunctionAbstract [14] => ReflectionFunction [15] => ReflectionParameter [16] => ReflectionMethod [17] => ReflectionClass [18] => ReflectionObject [19] => ReflectionProperty [20] => ReflectionExtension [21] => LibXMLError [22] => __PHP_Incomplete_Class [23] => php_user_filter [24] => Directory [25] => SimpleXMLElement [26] => DOMException [27] => DOMStringList [28] => DOMNameList [29] => DOMImplementationList [30] => DOMImplementationSource [31] => DOMImplementation [32] => DOMNode [33] => DOMNameSpaceNode [34] => DOMDocumentFragment [35] => DOMDocument [36] => DOMNodeList [37] => DOMNamedNodeMap [38] => DOMCharacterData [39] => DOMAttr [40] => DOMElement [41] => DOMText [42] => DOMComment [43] => DOMTypeinfo [44] => DOMUserDataHandler [45] => DOMDomError [46] => DOMErrorHandler [47] => DOMLocator [48] => DOMConfiguration [49] => DOMCdataSection [50] => DOMDocumentType [51] => DOMNotation [52] => DOMEntity [53] => DOMEntityReference [54] => DOMProcessingInstruction [55] => DOMStringExtend [56] => DOMXPath [57] => RecursiveIteratorIterator [58] => IteratorIterator [59] => FilterIterator [60] => RecursiveFilterIterator [61] => ParentIterator [62] => LimitIterator [63] => CachingIterator [64] => RecursiveCachingIterator [65] => NoRewindIterator [66] => AppendIterator [67] => InfiniteIterator [68] => RegexIterator [69] => RecursiveRegexIterator [70] => EmptyIterator [71] => ArrayObject [72] => ArrayIterator [73] => RecursiveArrayIterator [74] => SplFileInfo [75] => DirectoryIterator [76] => RecursiveDirectoryIterator [77] => SplFileObject [78] => SplTempFileObject [79] => SimpleXMLIterator [80] => LogicException [81] => BadFunctionCallException [82] => BadMethodCallException [83] => DomainException [84] => InvalidArgumentException [85] => LengthException [86] => OutOfRangeException [87] => RuntimeException [88] => OutOfBoundsException [89] => OverflowException [90] => RangeException [91] => UnderflowException [92] => UnexpectedValueException [93] => SplObjectStorage [94] => XMLReader [95] => XMLWriter [96] => Autoloader )[code] But I need some help. I built part of this script off a tut, and did the rest myself however, I want it so it send the information into a database. What I want is, once a user uploads an image, it can also be deleted by that user with the code given. I have made the html, bbcode & direct link. I want an option for a box where it shows Delete link.... maniaupload.net here's my FULL php upload script. Quote <?php define ("MAX_SIZE","100000"); function getExtension($str) { $i = strrpos($str,"."); if (!$i) { return ""; } $l = strlen($str) - $i; $ext = substr($str,$i+1,$l); return $ext; } $errors=0; if(isset($_POST['Submit'])) { $image=stripslashes($_FILES['image']['name']); if ($image) { $filename = stripslashes($_FILES['image']['name']); $extension = getExtension($filename); $extension = strtolower($extension); if (($extension != "jpg") && ($extension != "jpeg") && ($extension != "mov") && ($extension !="PNG") && ($extension !="bmp") && ($extension != "png") && ($extension != "gif")) { echo '<font color="red"><b>Extension not allowed</b></font><br>'; $errors=1; } else { $size=filesize($_FILES['image']['tmp_name']); if ($size > MAX_SIZE*100000) { echo 'You have exceeded the size limit!'; $errors=1; } $image_name=time().'.'.$extension; $newname="images/".$image_name; $fullname="http://www.maniaupload.net/".$newname; $copied = copy($_FILES['image']['tmp_name'], $newname); if (!$copied) { echo '<font color=\"red\"><b>Upload Unsuccessful! Try Again?</b></font>'; $errors=1; }}}} if(isset($_POST['Submit']) && !$errors) { echo "File Uploaded Successfully! <br /><br /> <img src=\"$newname\" /> <br /><br /> <b>Direct Image Link:</b><br/><table width=\"338\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\" id=\"Table1\"> <tr> <td align=\"center\" valign=\"middle\"><textarea readonly name=\"message\" rows=\"1\" cols=\"50\">$fullname</textarea></td> </tr> </table></center><br> <b>HTML Code:</b><br/><table width=\"338\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\" id=\"Table1\"> <tr> <td align=\"center\" valign=\"middle\"><textarea readonly name=\"message\" rows=\"1\" cols=\"50\"> <a href=\"$fullname\" target=\"_blank\"><img border=\"0\" src=\"$fullname\"></a> </textarea></td> </tr> </table><br> <b>BBCode <font color=\"red\">*NEW*</font></b><br> <table width=\"338\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\" id=\"Table1\"> <tr> <td align=\"center\" valign=\"middle\"> <textarea readonly name=\"message\" rows=\"1\" cols=\"50\"> </textarea></td> </tr> </table><br> "; } ?> I made the appropriate databases in the myadmin area, i just need a starting point to where it injects the image that was uploaded into the database. Basically the ID and all that crap. I have more code but its not needed, its outside of the php tags. But can anyone help please. It's just adding a delete link so users can delete it if they choose. I'm thinking it's MYSQL involved, but I'm still learning. Anyone know how I could do this? Thanks. Hello all, I've run into a problem with what seems to be a basic script. I want to display two different tables of data, side by side. Each table is built with a while loop, pulling data from an MySQL query. When I try to wrap the first table in a div the result is a div that appears empty when there is really a table with 60 rows of data I expect it to wrap around. I can't get this to work, I've tried to insert the div tag in many places to no avail. Also, I wanted to add some blank space at the bottom of the page so that there was room between the end of the table and the actual bottom of the page. I tried adding some <br />'s at the end of the code but that didn't work. I guess I'm confused because the code is acting as if the 60 rows of table data isn't there. When I tried to add my page layout around the script (as includes at the top and bottom of the script) the layout acts as if the table isn't there, either. That is to say that my "header" and "footer" appear bunched up at the top of the page as if there wasn't content on the screen. Hopefully someone can help! Thanks. Code: [Select] <?php echo "<br /> <a href='index.php'> Back Home </a> <br /> <br />"; // -------------------------- Connect to DB include ('connect_script.php'); // ------------------------------ Color variable for alternating table colors $color = 1; // ------------------------- Query Parameters $select = "SELECT (number) AS id, (first_name) AS fn, (last_name) AS ln, (position) AS position FROM table WHERE position = 'X' "; $get = @mysqli_query ($dbc, $select); // ------------------------- Run Query if ($get) { // ------------------------Start table echo " <div style='border-style: solid;'> <table align='left' border='1'> <tr> <td>People</td> </tr> <tr> <td>ID</td><td>First Name</td><td>Last Name</td><td>Position</td> </tr>"; // ------------------------ Retrieve People while ($row = mysqli_fetch_array($get, MYSQLI_ASSOC)) if ($color==1) {echo ' <tr bgcolor= #47EA7D> <td>' . $row['id'] . '</td><td>' . $row['fn'] . '</td><td>' . $row['ln'] . '</td><td>' . $row['position'] . '</td> </tr>'; $color = '2';} else {echo ' <tr bgcolor= #A4C8B0> <td>' . $row['id'] . '</td><td>' . $row['fn'] . '</td><td>' . $row['ln'] . '</td><td>' . $row['position'] . '</td> </tr> '; $color= '1';} // ----------------------- Close table echo "</div> </table>"; mysqli_free_result ($get); } // -------------------- IF ERROR WITH QUERY else {echo "Didn't connect";} // ---------------------- Spaces --> This is the code that doesn't appear to affect the space at the bottom of the table echo "<br /> <br /> <br />"; ?> Can anyone please help me write out a php script exactly as described below? In the submission form, users are required to filled in two infos,.. Name and email address. As soon as the 'submit' button is been clicked, the php script should be able to grab the filled infos and stores it on the server in a txt file and at the same time, it should sends out confirmation email to the email address so filled in the submission form. Also, can anyone devise a method as how to retrieve the message body of the confirmation email from the previous php script and then pass it on again to the display of the next page as when the submission button is clicked? Thank you so much in advance. This topic has been moved to Miscellaneous. http://www.phpfreaks.com/forums/index.php?topic=323879.0 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! 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. I dont no if this should even go here but here it goes. I created a blog were each blog post is veiwed on the same page in regards to the id passed to it (as standard). What i really need to do is incorporate the facebook comment box onto the page but... it only relates to the document itself rather than it's dynamic content. Following is the code that works fine if I am passing `/pageid/feed` to `facebook->api`, but when I change it to upload the image directly to my Facebook FAN PAGE photo album, it will not work. Kindly let me know what I am doing wrong in the following code: // Works fine $status = $facebook->api("/406221796071956/feed", 'post', $attachment); // Does not work $status = $facebook->api('/196878530339618/photos', 'post', $attachment); # Full Source Code: [Select] <?php require 'src/facebook.php'; $app_id = "364900470214655"; $app_secret = "xxxx"; $facebook = new Facebook(array( 'appId' => $app_id, 'secret' => $app_secret, 'cookie' => true, 'fileUpload' => true, )); $user = $facebook->getUser(); if(($facebook->getUser())==0){ header("Location:{$facebook->getLoginUrl(array('req_perms' => 'photo_upload,user_status,publish_stream,user_photos,offline_access,manage_pages'))}"); exit; } else { $accounts_list = $facebook->api('/me/accounts'); echo "i am connected"; } $valid_files = array('image/jpeg', 'image/png', 'image/gif'); // To get the page access token to post as a page foreach($accounts_list['data'] as $account){ if($account['id'] == 194458563914948){ // my page id =123456789 $access_token = $account['access_token']; echo "<p>Page Access Token: $access_token</p>"; } } // Posting to the page wall if(isset($_FILES) && !empty($_FILES)){ $folder = "pak/".$_FILES['pic']['name']; // Getting the path of the folder $fold = 'http://radiations3.com/facebook/'.$folder; // URL Path to folder echo $fold."<br>"; if(move_uploaded_file($_FILES['pic']['tmp_name'], $folder)){ # Upload photo here $img = realpath($_FILES["pic"]["tmp_name"]); $album_id = '406221796071956'; $attachment = array( 'message' => $_POST['textfield'], 'source' => $fold, 'aid' => $album_id, 'no_story' => 1, 'access_token' => $access_token ); $status = $facebook->api("/196878530339618/photos", 'post', $attachment); } else{ echo 'Only jpg, png and gif image types are supported!'; } } ?> <body> <!-- Form for uploading the photo --> <div class="main"> <p>Select a photo to upload on Facebook Fan Page</p> <form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>" enctype="multipart/form-data"> <p>Select the image: <input type="file" name="pic" /> <br /> <label>Description <input type="text" name="textfield" id="textfield" /> </label> </p> <p><input class="post_but" type="submit" value="Upload to my album" /></p> </form> </div> </body> 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 |