PHP - Facebook Like Older Post Script
I am working on a website where I have comments posted by users. I want to display 25 comments and if there are more, it will show a linke Older Posts similar to Facebook. Once I click on that, it will list down the next 25 comments and so on. This is something we can see in Facebook. Do you have any idea where I can find this script. I did search on google but couldn't find it. Probably bad keyword selection.
any ideas for the resource. Thanks, Faisal Similar TutorialsHi 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 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 :/ Hello, Have a question that i hope some one can help me answer. I have started creating a facebook app that will translate lovepoems. The problem im having is that facebook redirects everything wrong, which makes my life a living hell. So what i thought is it's possible to while submitting the form and the user gets redirected to the facebook allow app page, wait with submitting the form or maybe bring the post id with me and then post the content to the db liked to the post from a different page. simply so i don't have to make the accept form and then go to the actual content? So I'm using Wordpress as default CMS system if that helps. This is the code. Code: [Select] <?php /* Template Name: Febuary Love testing app */ ?> <SCRIPT LANGUAGE="JavaScript"> <!-- Original: Wayne Nolting (w.nolting@home.com) --> <!-- This script and many more are available free online at --> <!-- The JavaScript Source!! http://javascript.internet.com --> <!-- Begin function verify() { var themessage = "You are required to complete the following fields: "; if (document.form.title.value=="") { themessage = themessage + " - Title"; } if (document.form.description.value=="") { themessage = themessage + " - Poem"; } if (document.form.post_tags.value=="") { themessage = themessage + " - Keywords"; } //alert if fields are empty and cancel form submit if (themessage == "You are required to complete the following fields: ") { document.form.submit(); } else { alert(themessage); return false; } } // End --> </script> <?php add_filter('fb_php_sdk_load','your_filter'); function your_filter($array) { $array[] = '2.1.2'; //exact version number you need return $array; } $facebook = new Facebook(array( 'appId' => '179200268852090', 'secret' => '3b62bc6b207e4038aa56a28bfc5ed368', 'cookie' => true, )); $session = $facebook->getUser(); if (!empty($session)) { try{ $user = $facebook->getUser(); $user = $facebook->api('/me'); } catch (Exception $e){ } if (!empty($user)) { } else die ("An error occured"); } else{ $loginUrl = $facebook->getLoginUrl(array( 'canvas' => 1, 'fbconnect' => 0, 'scope' => 'offline_access, publish_stream' )); echo "<a href='".$loginUrl."'>Click </a> to add the Copypanther Facebook application"; } ?> <?php $user = $facebook->getUser(); if($user){ $access_token = $facebook->getAccessToken(); } ?> <?php if( 'POST' == $_SERVER['REQUEST_METHOD'] && !empty( $_POST['action'] ) && $_POST['action'] == "new_post") { // Do some minor form validation to make sure there is content if (isset ($_POST['title'])) { $title = $_POST['title']; } else { echo 'Please enter the Poem name'; } if (isset ($_POST['description'])) { $description = $_POST['description']; } else { echo 'Please enter some notes'; } $tags = $_POST['post_tags']; $access_token = $_POST['access_token']; $user = $_POST['user']; // ADD THE FORM INPUT TO $new_post ARRAY $new_post = array( 'post_title' => $title, 'post_content' => $description, 'post_category' => array($_POST['cat']), // Usable for custom taxonomies too 'tags_input' => array($tags), 'post_status' => 'draft', // Choose: publish, preview, future, draft, etc. 'post_type' => 'post', //'post',page' or use a custom post type if you want to 'access_token' => $access_token, 'user' => $user, ); //SAVE THE POST $pid = wp_insert_post($new_post); add_post_meta($pid, 'access_token', $access_token, true); add_post_meta($pid, 'user', $user, true); //SET OUR TAGS UP PROPERLY wp_set_post_tags($pid, $_POST['post_tags']); //REDIRECT TO THE NEW POST ON SAVE $link = get_permalink( $pid ); wp_redirect('http://www.ngee.se'); } // END THE IF STATEMENT THAT STARTED THE WHOLE FORM //POST THE POST YO do_action('wp_insert_post', 'wp_insert_post'); get_header(); ?> <?php if ( have_posts() ) while ( have_posts() ) : the_post(); ?> <div class="form-content"> <?php the_content(); ?> <!-- WINE RATING FORM --> <div class="wpcf7"> <h2>Share some February Love!</h2> <p>Although the 14th of February might and should be dedicated to your loved one, we think that friends, bosses and coworkers deserve some affection, too. So between the 1st and 13th of February we will translate a poem or message from you to them <em>for free</em></p> <form id="new_post" name="new_post" method="post" action="" class="wpcf7-form" enctype="multipart/form-data"> <!-- post name --> <fieldset name="name"> <label for="title">Love poem name:</label> <input type="text" id="title" value="" tabindex="5" name="title" /> </fieldset> <!-- post Category --> <fieldset class="category"> <label for="cat">Translate to:</label> <?php wp_dropdown_categories( 'tab_index=10&taxonomy=category&hide_empty=0' ); ?> </fieldset> <!-- post Content --> <fieldset class="content"> <label for="description">Love poem:</label> <textarea id="description" tabindex="15" name="description" cols="80" rows="10"></textarea> </fieldset> <!-- post tags --> <fieldset class="tags"> <label for="post_tags">Keywords (comma separated):</label> <input type="text" value="" tabindex="35" name="post_tags" id="post_tags" /> </fieldset> <SCRIPT LANGUAGE="JavaScript"> function testResults (form) { var TestVar = form.submit(); } </SCRIPT> <fieldset class="submit"> <input type=button value="Send" value="Send" tabindex="40" id="submit" name="submit" onclick="verify();"> </fieldset> <fieldset class="access_token"> <label for="access_token"></label> <input type="text" value="<?php echo $access_token;?>" id="access_token" name="access_token"/> </feildset> <fieldset class="user"> <label for="user"></label> <input type="text" value="<?php echo $user;?>" id="user" name="user" /> </feildset> <input type="hidden" name="action" value="new_post" /> <?php wp_nonce_field( 'new-post' ); ?> </form> </div> <!-- END WPCF7 --> <?php wp_link_pages( array( 'before' => '<div class="page-link">' . __( 'Pages:', 'twentyten' ), 'after' => '</div>' ) ); ?> <?php edit_post_link( __( 'Edit', 'twentyten' ), '<span class="edit-link">', '</span>' ); ?> </div><!-- .entry-content --> </div><!-- #post-## --> <?php endwhile; // end of the loop. ?> <?php get_footer(); ?> Any one have any idea about how i can solve this problem ? Answers most appreciated! Best Regards GrundeLL EDIT *** I'm using facebook PHP SDK kindly check the following code i am trying to make such an script that'll allow you to upload images on facebook from your site i am running this script locally but getting different errors like Facebook.php is being downloaded from facebook api's (Kindly provide any other working example that would be fine with me too i just need the functionality) Warning: Missing argument 2 for Facebook::__construct(), called in C:\Users\Administrator\Desktop\face\abc.php on line 16 and defined in C:\Users\Administrator\Desktop\face\library\facebook.php on line 64 Notice: Undefined variable: secret in C:\Users\Administrator\Desktop\face\library\facebook.php on line 66 Notice: Undefined variable: secret in C:\Users\Administrator\Desktop\face\library\facebook.php on line 68 Fatal error: Call to undefined method Facebook::api() in C:\Users\Administrator\Desktop\face\abc.php on line 31 Code: [Select] <html> <head> <title> Upload images to Facebook</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> </head> <body> <?php $app_id = 332267477347; $app_secret = "989b7e58b48f17b3463ee54ea9c4f88d"; require_once 'library/facebook.php'; $facebook = new Facebook(array( 'appId' => $app_id, 'secret' => $app_secret, 'fileUpload' => true )); //It can be found at https://developers.facebook.com/tools/access_token/ $access_token = 'I pout here the key of my profile'; $params = array('access_token' => $access_token); //The id of the fanpage $fanpage = '194458563914948'; //The id of the album $album_id ='406221796071956'; //Replace arvind07 with your Facebook ID $accounts = $facebook->api('/faizan.gemeni/accounts', 'GET', $params); foreach($accounts['data'] as $account) { if( $account['id'] == $fanpage || $account['name'] == $fanpage ){ $fanpage_token = $account['access_token']; } } $valid_files = array('image/jpeg', 'image/png', 'image/gif'); if(isset($_FILES) && !empty($_FILES)){ if( !in_array($_FILES['pic']['type'], $valid_files ) ){ echo 'Only jpg, png and gif image types are supported!'; }else{ #Upload photo here $img = realpath($_FILES["pic"]["tmp_name"]); $args = array( 'message' => 'This photo was uploaded via WebSpeaks.in', 'image' => '@' . $img, 'aid' => $album_id, 'no_story' => 1, 'access_token' => $fanpage_token ); $photo = $facebook->api($album_id . '/photos', 'post', $args); if( is_array( $photo ) && !empty( $photo['id'] ) ){ echo '<p><a target="_blank" href="http://www.facebook.com/photo.php?fbid='.$photo['id'].'">Click here to watch this photo on Facebook.</a></p>'; } } } ?> <!-- Form for uploading the photo --> <div > <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" /></p> <p><input class="post_but" type="submit" value="Upload to my album" /></p> </form> </div> </body> </html> 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! Can I post my "Add a Comment" script here to get help improving it? Debbie Hi all, Since twitter changed the way they allow people to post, my simple php script to grab the $_POST data from an input and post it to my twitter profile has broken. I've been reading up on Oauth, but none of the documentation is clear at all. It's quite complex, in fact - they assume you are creating a full app, which I am not - I just want to flick some text to twitter. I just want to pass a simple string variable to my account - can anyone help me with how to do this? All help appreciated. WoolyG Is there a quick an easy way to test my php scripts without creating an html form and specifying values that I post to my php script? Maybe a firefox plugin or some tool that can be used to do it quicker? In the long haul, quicker, not just one time I have a page, that upon post, does some logic, this logic can take 1-30 minutes... Now sometimes I will get a "Page time out"....and others i wont... even if im requesting the same data. I used it successfully everytime on my stock xp, with ie8 But cant get it to work on my VISTA WIN7 x64 machins, and another xp machine, after about 1-5 min it says "page time out", then i test it on my stock xp machine, and it can run for 45 min, or runs until everything is finsihed and shows the page. Any ideas? Its just keep saying error on line 1 if($_POST["pass"] == $_POST["repass"]){ arepasssame = $_POST[pass]; } I have a problem about Blog Post Categorization Script. Can anyone review it ? Instead of showing how much posts that category have it just repeats. Code: [Select] <? $sqlCategories = "SELECT * FROM blog_entry, categories where blog_entry.CategoryID=categories.CategoryID and blog_entry.UserID=".$_REQUEST['UserID']." order by Category asc"; $resultCategories = mysql_query($sqlCategories, $conn); if (@mysql_num_rows($resultCategories)!=0){ $strcategory=""; while($row_categories = @mysql_fetch_array($resultCategories)) { $categoryduplicate=0; $arrcat = explode(",",$strcategory); for($i=0;$i<strlen($arrcat);$i++) { if($arrcat[$i]==$row_categories['CategoryID']) { $categoryduplicate=1; } } if($categoryduplicate==0) { if($strcategory=="") { $strcategory=$row_categories['CategoryID']; } else { $strcategory=$strcategory.",".$row_categories['CategoryID']; } $sqlCategories2 = "SELECT * FROM blog_entry where CategoryID=".$row_categories['CategoryID']." and UserID=".$_REQUEST['UserID']; $resultCategories2 = mysql_query($sqlCategories2, $conn); if($row_categories['CategoryID'] == $_REQUEST['CategoryID']) { echo " <Tr> <td class='content'><a href='postss.php?CategoryID=".$row_categories['CategoryID']."&UserID=".$_REQUEST['UserID']."&Category=".$row_categories['Category']."' class='in_sel'>".$row_categories['Category']."</a> [".@mysql_num_rows($resultCategories2)."]</td> </Tr> "; } else { echo " <Tr> <td class='content'><a href='posts.php?CategoryID=".$row_categories['CategoryID']."&UserID=".$_REQUEST['UserID']."&Category=".$row_categories['Category']."' class='in_sel'>".$row_categories['Category']."</a> [".@mysql_num_rows($resultCategories2)."]</td> </Tr> "; } } } } ?> Hello guys, Is there on web any updated tutorial on how can I add Facebook login on my simple php login script? <td> <button onclick="alertdialog()"><span class="glyphicon glyphicon-trash"> </span></button></td> <script> function alertdialog(){ window.confirm("Are you sure you want to delete this post?"); } </script> This is my code. I need to have a callback to a PHP script when a user decides to delete a post. I think html POST is the most unobtrustive way to do this. What's the easiest / most robust way to send data to a script when the user clicks OK? Appreciated. Mark I've managed to isolate a problem I'm having with my php script. It would seem the script randomly restarts itself with blank post data while it's running. I've managed to mimick the problem using a very basic php script which just pauses and writes to a log: <?php $q = $_POST['q']; if ($q==""){ writelog ("MISFIRE!!!"); die; } writelog("\n*** Error check started ***"); for ($i = 1; $i <= 50; $i++) { writelog ($i); sleep(rand(2,20)); } function writelog($towrite) { $tdate=date('d/m/Y H:i:s'); $file = 'log/testlog.txt'; $current = $towrite." --- ".$tdate."\n"; file_put_contents($file, $current, FILE_APPEND); } writelog("*** Error check ended ***"); ?>To rule out any problems with my AJAX htmlhttp requests, I simply send the script some irrelevant post data using Chrome's Advanced Restful client. This is the ouput of the log from an example test run: *** Error check started *** --- 05/06/2014 18:27:30 1 --- 05/06/2014 18:27:30 2 --- 05/06/2014 18:27:44 3 --- 05/06/2014 18:27:49 4 --- 05/06/2014 18:27:59 5 --- 05/06/2014 18:28:04 6 --- 05/06/2014 18:28:22 7 --- 05/06/2014 18:28:33 8 --- 05/06/2014 18:28:39 9 --- 05/06/2014 18:28:52 10 --- 05/06/2014 18:29:08 11 --- 05/06/2014 18:29:22 12 --- 05/06/2014 18:29:30 13 --- 05/06/2014 18:29:43 MISFIRE!!! --- 05/06/2014 18:29:46 14 --- 05/06/2014 18:29:56 15 --- 05/06/2014 18:30:07 16 --- 05/06/2014 18:30:09 17 --- 05/06/2014 18:30:15 18 --- 05/06/2014 18:30:32 19 --- 05/06/2014 18:30:52 20 --- 05/06/2014 18:30:54Note the logged "Misfire" after the 13th entry. This shows the script tried to run again with blank post data, the same problem I'm having in my more complex script. Why could this be happening? It's not anyone else calling the script, nobody knows about the site and I've ruled it out by logging the IP in my real script. Edited by holdorfold, 05 June 2014 - 02:29 PM. ok..ive done this a million times..i have a working example here and i copied it and amended it for this new project but for some reason i cant get a form to post data to another page. this is the error message i get Notice: Undefined index: username in C:\wamp\www\uni\fyp\site\mobile\login.php on line 16 Notice: Undefined index: password in C:\wamp\www\uni\fyp\site\mobile\login.php on line 17 here is my form code: <form method="post" action="login.php"> <table align="center" cellpadding="0" cellspacing="0"> <tr> <td style="vertical-align:top;">Username: </td><td><input type="text" name="username" value="" /></td> </tr> <tr> <td style="vertical-align:top;">Password: </td><td><input type="password" name="password" value="" /><br /><input type="submit" id="submit" value="Login" /></td> </tr> </table> </form> and here is the code within the login.php where the form should post to $username = $_POST['username']; $password = $_POST['password']; // Help protect against MySQL injection $username = stripslashes($username); $password = stripslashes($password); $username = mysql_real_escape_string($username); $password = mysql_real_escape_string($password); // Selecting data from database where correct username and password are found $sql="SELECT * FROM customer WHERE username='$username' and password='$password'"; $result=mysql_query($sql) or die(mysql_error()); i cant see anything wrong..been looking for hours...please please help me Hi all, Thanks for reading. I'm hella frustrated at this script I wrote: for some reason, it will not work correctly. Basically, it works. The first 4 names in the table on the database show up when searched. But, anything past these four names in the database will not show up as a result when searched! I'm pulling my hair out here! It's really simple - take a gander: Code: [Select] if (isset($_POST['submit'])) { $search = $_POST['search']; $searchQuery = mysql_query("SELECT * FROM Accounts WHERE FullName='$search'"); if (mysql_num_rows($searchQuery) == 0) { $result = "Your search returned no results. Please try again."; } else { $results = 1; while ($getSearchResults = mysql_fetch_array($searchQuery)) { $fullName = $getSearchResults['FullName']; $result = "Name: ".$fullName.""; } } } ?> ...and the HTML form... Code: [Select] <form action="search.php" method="post"> <p>Search: <input type="text" name="search" size="35" maxlength="100" /></p> <p><input type="submit" value="Search" name="submit" /></p> <?php echo $result; ?> </form> Does anyone have any ideas? Hi guys, I using the following code if ($handle = opendir('temp_photo')) { while (false !== ($file = readdir($handle))) { $filelastmodified = filemtime($file); if(($filelastmodified-time()) > 24*3600) { unlink($file); } } closedir($handle); } I want it to look in the directory and remove all the files that are older than 24 hours old. When I run the code I get the following error.. Warning: filemtime() [function.filemtime]: stat failed for image1.jpg Warning: filemtime() [function.filemtime]: stat failed for image2.jpg Warning: filemtime() [function.filemtime]: stat failed for image3.jpg Warning: filemtime() [function.filemtime]: stat failed for image4.jpg It seems to read the directory, but it doesn't remove them and I receive the error message. Any ideas of what may be going on or do you have a script that may resolve this issue? Thanks, Dan I have a table with several fields, one of which is an amount of days after which the row will be deleted. Every time the script is run, I want to check for old entries and delete them. How would I do this? I just have a general question about when other programmers remove rows older than say a year old.... Do most of you: 1) set up a CRON job to run daily at 3:00am 2) Add a routine at login for each user 3) Add a routine when a user moves into a certain portion of the application 4) A maintenance routine that an administrator manually has to envoke Or is there another way...I have done some research but most of the things google has showed me is the how not when to do this... I've been researching online resources and seen a lot of code and functions for calculating an interval or difference between two date/time figures. What I'm trying to do is somewhat in reverse... I want to establish an interval to determine a past date/time to be used in a MySQL Query but just can't figure the critical part.
// STEP #1 = DEFINE THE DESIRED DATE/TIME DIFFERENCE INTERVAL DESIRED FOR QUERIES $timeinterval = '60'; // Interval is in MINUTES and can be changed as desired // STEP #2 = GET THE CURRENT LOCAL SERVER DATE/TIME // as YYYY-MM-DD HH:MN:SE $serverdatetime = date('Y-m-d H:i:s'); // My local Server Date & time // STEP #3 = CALCULATE THE ***PAST** (OLDER) DATE/TIME LIMIT BASED ON $timeinterval (Minutes) // as YYY-MM-DD HH:MN:SE $pastdatetime = [stuckinarut here] <- 60 MINUTES prior to current Server Date/Time // STEP #4 = MySQL QUERY (`submitted` column is auto-timestampped on record insertions) $sql="[columnsblahblah] FROM mydb WHERE `submitted` >= $pastdatetime";In a Perfect World, the MySQL Query would yield ONLY records with a `submitted` DATE/TIME equal to 60 Minutes (or less) PRIOR TO from the Current Server Time. Any assistance is appreciated! Thanks. -FreakingOUT |