PHP - Not Able To Create A Facebook Like Timeline
i'm trying to print posts just like facebook timeline with infinite scroll jquery and php, mysql. i wrote a inner join mysql query to fetch posts from groups and updates. The problem is i'm plagued by duplicate posts and unable to separate the group posts from updates in raw data. i tried a couple of times to sepearate and place them in jumbotron classes but i fail. Though the code is lengthy i hope to find some corrections and answers by sharing it. i need to prevent duplicate posts coming up through the query and printing while the ajax request go through's too. PHP class query: public function totalUpdates($friend,$session,$var_id, $load) { try{ $sql2="select distinct g.*,u.avatar,u.user_id,up.* from group_posts as g " . " join user as u on uname=g.author_gp " . " join updates as up on u.uname=up.author" . " where g.gname='MEP news' and (up.update_id >:update_id_all or g.gp_id>:update_id_all) and up.author in(:friend, :session) order by time,pdate desc limit $load,5 "; //$sql2="SELECT distinct update_id,update_body,time,title,user_id_u,account_name,author,data FROM updates where author in(:friend,:session) and update_id not in(:update_id_all) order by time desc limit $load,5"; $stmth= $this->_db->prepare($sql2);//Check here syntax of $db $stmth->bindValue(":friend",$friend); $stmth->bindValue(":session",$session); $stmth->bindValue(":update_id_all",$var_id); //$stmth->bindValue(":update_id2",$update_id2); $stmth->execute(); return $stmth->fetchAll(); } catch (PDOException $ei){ echo $ei->getMessage(); } } PHP script that prints values: $f = array(); $ids= array(); $stmt= $conn->prepare("select friend_one, friend_two from friends where (friend_one=:session OR friend_two=:session) and (friend_one>=:session or friend_two>=:session) and accepted='1'"); $stmt->bindparam(":session",$_SESSION['uname']); $stmt->execute(); $f=$stmt->fetchAll(); $f_count=count($f); $ids= ff($f, $project); //$k=0; //for ($k=0;$k<count($ids);$k++){ //while($i<$f_count){ //$id=$v; //$i=0; //foreach ($update_id1 as $i => $v) { $ex= explode(",", $update_id1[0]); $unique=array_unique($ex); $im= implode(",", $unique); //fetch username from update table in db and inject it to the feed query. $imp_id="'" .join( "','", $ids)."'";
*we get the $sess_count and $load from javascript in home page and forward the logic if load*2 is greater than
var load=0; var sess_uname="<?php echo $session_uname;?>"; var f_uname="<?php echo htmlspecialchars($_GET['u']);?>"; var sess_count="<?php echo $total_sess_count;?>"; var f_count="<?php echo $total_friend_count;?>"; var funame="<?php echo $f_uname0;?>"; $(".message").html("<div style='display: flex; justify-content: center;'><h1>Loading Posts...</h1> "+spinner1+"</div>").show(); if(sess_uname==f_uname){ $(window).scroll(function(){ //alert($(window).scrollTop()); // alert($(window).scrollTop()+" "+$(document).height()-$(window).height()); if($(window).scrollTop()==$(document).height()-$(window).height()){ var sub=$(document).height()-$(window).height(); //lert(sub); // alert($(window).scrollTop()+" "+sub); load++; var ids1=[]; var ids=$(".i-select i").text(); ids1.push(ids); //var arr=$(ids).serializeArray(); var arrJSON=JSON.stringify( ids1); var strids=ids.toString(); var newids = strids.split(","); var len=newids.length; // alert(newids); // for(x=0;x<len;x++){ // alert('ids:- ' + newids[x] +" len:- "+ len); var newid1=newids[load]; // alert(newids[x]); var first=$(".i-select i:first").text(); var last= $("i:last").text(); //console.log(first+"--1---2-- "+last); // alert(load+" "+sess_count); if(load * 5< sess_count){ $(".message").html("<h1>no more posts to show </h1>"); } else{ $.post("st&com.php", {"load":load,"sess_count":sess_count,"update_id2":last,"update_id1":arrJSON},function(data){ $(".message").html(spinner1).show(); $("#status_area").append(data); $(".hide").hide(); $(".message").html(spinner1).hide(); }); } } }); }else { $(window).scroll(function(){ if($(window).scrollTop()==$(document).height()-$(window).height()){ load++; // alert($(window).scrollTop()+" "+$(document).height()-$(window).height()); if(load *2 >f_count){ $(".message").html("<h1>no more posts to show here</h1>"); }else{ $.post("status_list.php", {funame:funame, load:load},function(data){ $(".message").html(spinner1).show(); $("#status_area").append(data); $(".hide").hide(); $(".message").html(spinner1).hide(); }); } } }); } sample output: Array ( [gp_id] => 103 [0] => 103 [pid] => 0 [1] => 0 [gname] => MEP news [2] => MEP news [author_gp] => aboutthecreator [3] => aboutthecreator [type] => a [4] => 0 [title] => qwertyu [5] => 2 [data] => [6] => <div>Etiam iaculis nunc ac metus. Praesent egestas tristique nibh.</div> <div> </div> <div>Fusce ac felis sit amet ligula !qwerty pharetra condimentum. Integer ante arcu, accumsan a, consectetuer eget, posuere ut, mauris.</div> <div> </div> <div>Proin viverra, ligula sit amet ultrices semper, ligula arcu tristique sapien !bart, a accumsan nisi mauris ac eros. Sed in libero ut nibh placerat accumsan.</div> <div> </div> <div>Phasellus leo dolor, tempus non, auctor et, hendrerit quis, nisi. Sed a libero. !qwerty</div> [pdate] => 2019-12-19 22:28:04 [7] => 2019-12-19 22:28:04 [vote_up] => 0 [8] => 0 [vote_down] => 0 [9] => 0 [group_id] => 25 [10] => 25 [author_id] => 142 [11] => 142 [avatar] => ThuJul1821235420191075.jpg [12] => ThuJul1821235420191075.jpg [user_id] => 142 [13] => 142 [update_id] => 381 [14] => 381 [update_body] => Lorem ipsum dolor sit amet,consetetur sadipscing elitr, no sea takimata sanctus est Lorem ipsum dolor sit amet. no sea takimata sanctus est Lorem ipsum dolor sit amet. no sea takimata sanctus est Lorem ipsum dolor sit amet. no sea takimata sanctus est Lorem ipsum dolor sit amet. sed diam voluptua. Lorem ipsum dolor sit amet, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, Lorem ipsum dolor sit amet, <a href="home.php?u=shan2batman">@shan2batman</a><br /><br />Lorem ipsum dolor sit amet,consetetur sadipscing elitr, sed diam voluptua. !qwerty Lorem ipsum dolor sit amet, consetetur sadipscing elitr, Lorem ipsum dolor sit amet, At vero eos et accusam et justo duo dolores et ea rebum. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, Stet clita kasd gubergren, <br /><br />Lorem ipsum dolor sit amet,sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, Stet clita kasd gubergren, consetetur sadipscing elitr, sed diam voluptua. sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, At vero eos et accusam et justo duo dolores et ea rebum. sed diam voluptua. no sea takimata sanctus est Lorem ipsum dolor sit amet. <br /><br />Lorem ipsum dolor sit amet,sed diam voluptua. Lorem ipsum dolor sit amet, sed diam voluptua. sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, At vero eos et accusam et justo duo dolores et ea rebum. sed diam voluptua. sed diam voluptua. Stet clita kasd gubergren, <br /><br />Lorem ipsum dolor sit amet,no sea takimata sanctus est Lorem ipsum dolor sit amet. Stet clita kasd gubergren, At vero eos et accusam et justo duo dolores et ea rebum. consetetur sadipscing elitr, At vero eos et accusam et justo duo dolores et ea rebum. sed diam voluptua. Lorem ipsum dolor sit amet, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, Stet clita kasd gubergren, <br /><br />Lorem ipsum dolor sit amet,consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, At vero eos et accusam et justo duo dolores et ea rebum. sed diam voluptua. sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. sed diam voluptua. <br /><br />Lorem ipsum dolor sit amet,consetetur sadipscing elitr, At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. sed diam voluptua. consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, <br /><br />Lorem ipsum dolor sit amet,Lorem ipsum dolor sit amet, consetetur sadipscing elitr, At vero eos et accusam et justo duo dolores et ea rebum. consetetur sadipscing elitr, At vero eos et accusam et justo duo dolores et ea rebum. At vero eos et accusam et justo duo dolores et ea rebum. no sea takimata sanctus est Lorem ipsum dolor sit amet. sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, consetetur sadipscing elitr, <br /><br />Lorem ipsum dolor sit amet,Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam voluptua. Stet clita kasd gubergren, Lorem ipsum dolor sit amet, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Lorem ipsum dolor sit amet, Lorem ipsum dolor sit amet, <br /><br />Lorem ipsum dolor sit amet,At vero eos et accusam et justo duo dolores et ea rebum. sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, At vero eos et accusam et justo duo dolores et ea rebum. consetetur sadipscing elitr, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, Lorem ipsum dolor sit amet, sed diam voluptua. Stet clita kasd gubergren, <br /><br /> [15] => Lorem ipsum dolor sit amet,consetetur sadipscing elitr, no sea takimata sanctus est Lorem ipsum dolor sit amet. no sea takimata sanctus est Lorem ipsum dolor sit amet. no sea takimata sanctus est Lorem ipsum dolor sit amet. no sea takimata sanctus est Lorem ipsum dolor sit amet. sed diam voluptua. Lorem ipsum dolor sit amet, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, Lorem ipsum dolor sit amet, <a href="home.php?u=shan2batman">@shan2batman</a><br /><br />Lorem ipsum dolor sit amet,consetetur sadipscing elitr, sed diam voluptua. !qwerty Lorem ipsum dolor sit amet, consetetur sadipscing elitr, Lorem ipsum dolor sit amet, At vero eos et accusam et justo duo dolores et ea rebum. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, Stet clita kasd gubergren, <br /><br />Lorem ipsum dolor sit amet,sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, Stet clita kasd gubergren, consetetur sadipscing elitr, sed diam voluptua. sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, At vero eos et accusam et justo duo dolores et ea rebum. sed diam voluptua. no sea takimata sanctus est Lorem ipsum dolor sit amet. <br /><br />Lorem ipsum dolor sit amet,sed diam voluptua. Lorem ipsum dolor sit amet, sed diam voluptua. sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, At vero eos et accusam et justo duo dolores et ea rebum. sed diam voluptua. sed diam voluptua. Stet clita kasd gubergren, <br /><br />Lorem ipsum dolor sit amet,no sea takimata sanctus est Lorem ipsum dolor sit amet. Stet clita kasd gubergren, At vero eos et accusam et justo duo dolores et ea rebum. consetetur sadipscing elitr, At vero eos et accusam et justo duo dolores et ea rebum. sed diam voluptua. Lorem ipsum dolor sit amet, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, Stet clita kasd gubergren, <br /><br />Lorem ipsum dolor sit amet,consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, At vero eos et accusam et justo duo dolores et ea rebum. sed diam voluptua. sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. sed diam voluptua. <br /><br />Lorem ipsum dolor sit amet,consetetur sadipscing elitr, At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. sed diam voluptua. consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, <br /><br />Lorem ipsum dolor sit amet,Lorem ipsum dolor sit amet, consetetur sadipscing elitr, At vero eos et accusam et justo duo dolores et ea rebum. consetetur sadipscing elitr, At vero eos et accusam et justo duo dolores et ea rebum. At vero eos et accusam et justo duo dolores et ea rebum. no sea takimata sanctus est Lorem ipsum dolor sit amet. sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, consetetur sadipscing elitr, <br /><br />Lorem ipsum dolor sit amet,Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam voluptua. Stet clita kasd gubergren, Lorem ipsum dolor sit amet, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Lorem ipsum dolor sit amet, Lorem ipsum dolor sit amet, <br /><br />Lorem ipsum dolor sit amet,At vero eos et accusam et justo duo dolores et ea rebum. sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, At vero eos et accusam et justo duo dolores et ea rebum. consetetur sadipscing elitr, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, Lorem ipsum dolor sit amet, sed diam voluptua. Stet clita kasd gubergren, <br /><br /> [url] => [16] => [time] => 2018-11-10 22:58:36 [17] => 2018-11-10 22:58:36 [host] => [18] => [19] => 0 [20] => 0 [21] => qwertyu [user_id_u] => 142 [22] => 142 [account_name] => aboutthecreator [23] => aboutthecreator [author] => aboutthecreator [24] => aboutthecreator [25] => a [26] => )
Similar TutorialsHello PHP Freaks! I have the following PHP Curl code which is supposed to fetch the twitter timeline feed for a specific username and parse and display it on a page, but for some reason Curl is unable to fetch data from twitter: Code: [Select] <?php function get_data($url) { $ch = curl_init(); $timeout = 5; curl_setopt($ch,CURLOPT_URL,$url); curl_setopt($ch,CURLOPT_RETURNTRANSFER,1); curl_setopt($ch,CURLOPT_CONNECTTIMEOUT,$timeout); $data = curl_exec($ch); curl_close($ch); return $data; } $json = get_data("https://api.twitter.com/1/statuses/user_timeline.json?include_entities=true&include_rts=true&screen_name=digioz&count=2"); if ($json != false) { $obj = json_decode($json); foreach($obj as $var => $value) { echo "Message number: $var <br/>"; echo "Name: " . $obj[$var]->user->name; echo "Handle: " . $obj[$var]->user->screen_name . "<br/>"; echo "Message: " . $obj[$var]->text; echo "Created" . $obj[$var]->created_at . "<br/>"; echo "URL" . $obj[$var]->user->url . "<br/>"; echo "Location" . $obj[$var]->user->location . "<br/>"; echo "<br/>"; } } else { echo "Could not fetch Twitter Data"; } ?> Anyone have any idea why the data is not being fetched? If I copy and paste the URL into my browser window it returns results just fine, so I know the problem is not with the URL. Thanks, Pete Hello everyone, I am working on a form that is similar to a shopping cart system and I am thinking of creating a button that submits the checked value and saves them to a $_SESSION variable. And also a link that links to a cart.html that takes the values of a $_SESSION variable. I am have trouble figuring what tag/attribute should I use in order to achieve that.
Right now my code attached below submits the checked values to cart.html directly. However I want my submit button to save the checked box to a $_SESSION variable and STAY on the same page. And then I will implement a <a> to link to the cart.php.
I researched a little bit about this subject and I know it's somewhat related to ajax/jquery. I just wanted to know more about it from you guys. I appreciate your attention for reading the post and Thanks!
Below is the form that I currently have:
<form name= "finalForm" method="POST" action="cart.php"> <input type="Submit" name="finalSelected"/> <?php foreach($FinalName as $key => $item) {?> <tr> <td><input type="checkbox" name="fSelected[]" value="<?php echo htmlspecialchars($FinalID[$key])?>" /> <?php echo "$FinalID[$key] & $item";?> </td> </tr> <?php } ;?>Below is the code for cart.php <?php require ('connect_db.php'); if(isset($_POST['finalSelected'])) { if(!empty($_POST['fSelected'])) { $chosen = $_POST['fSelected']; foreach ($chosen as $item) echo "aID selected: $item </br>"; $delimit = implode(", ", $chosen); print_r($delimit); } } if(isset($delimit)) { $cartSQL = "SELECT * from article where aID in ($delimit)"; $cartQuery = mysqli_query($dbc, $cartSQL) or die (mysqli_error($dbc)); while($row = mysqli_fetch_array($cartQuery, MYSQLI_BOTH)) { $aTitle[] = $row[ 'name' ]; } } ?> <table> <?php if(isset($delimit)) { $c=0; foreach($aTitle as $item) {?> <tr> <td> <?php echo $aTitle[$c]; $c++;?> </td> </tr> <?php }}?> </table> 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. Hi, I'm having problems with my phpbb forum/facebook coding. I have recently put Facebook Share links in my forum... The facebook 'Share' links(buttons), are attached to every post viewable within th eforum, and link to: http://www.facebook.com/sharer.php?u=http://www.mywebsite.com/facebook/share-fb.php?postNo=" . $postrow[$i]['post_id'].'&title='.$userdata['username'].'%20on%20facebook!!' --> where '$userdata['username']' username of forum user ..and '$postrow[$i]['post_id']' = the id of the forum post, to be processed by share-fb.php So as according to he http://developers.facebook.com/docs/share under the Basics section, I will be able to control the thumbnail, title and content from Quote You can control the exact title, description, and thumbnail that Facebook Share uses by adding the following meta tags to the <head> element in your page: So the url looks like this: http://www.anclchess.net/facebook/share.php?postNo=65914&title=My%20Names%20on%20facebook!!Title%20of%20post There are 2 major problems. 1) I am passing the post number identity via URL.. which means anyone wanting to view posts they may not have permissions to view, would simply need to change the share.php?postNo=65914&title= and they would have access.. and 2) The the thumbnail, title and content don't seem to work.. I cant figure out why.. see below This is 'share-fb.php': <?php define('IN_PHPBB', true); // allows infomation to be passed to external page, such as '$userdata['username'] '(username) $phpbb_root_path = '../forum/'; include($phpbb_root_path . 'extension.inc'); include($phpbb_root_path . 'common.'.$phpEx); // // Start session management // $userdata = session_pagestart($user_ip, PAGE_INDEX); init_userprefs($userdata); // // End session management // ?> <?php $postIdent = $_GET['postNo']; // gets forum post identity from URL, to then later query.. \\ $titleIdent = $_GET['title']; // gets title of post from URL too \\ if($userdata['session_logged_in']) { //echo'Hello ' . $userdata['username'] . '. The facebook system is not yet up-and-running. Please try later.<br>'; // <-works \\ $sql = "SELECT post_id, post_subject, post_text FROM phpbb_posts_text WHERE post_id='$postIdent'"; if( !($result = $db->sql_query($sql)) ) { message_die(CRITICAL_ERROR, "Could not query config information", "", __LINE__, __FILE__, $sql); } while ( $row = $db->sql_fetchrow($result) ) // executes database query \\ { $postSubject = $row['post_subject']; $postText = $row['post_text']; } $pattern = '#\[[^\]]+\]#'; $postTextFormat = preg_replace($pattern, '', $postText); // this search and replaces the forum square brackets code such as: '[ url ]' & '[ /url ]' content ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title></title> // left empty \\ <script src="http://static.ak.fbcdn.net/connect.php/js/FB.Share" type="text/javascript"> </script> <meta name="title" content="<?php echo echo $titleIdent; ?>" /> // this doesnt work - I don't know why. The variables work in the <body> but not here \\ <meta name="description" content="<?php echo $postSubject.$postTextFormat; ?>" /> <link rel="image_src" href="http://www.mywebsite.com/images/website_log.png" /> </head> <body> <?php echo $postSubject.'<br>'.$postTextFormat; // contains content of forum post \\ ?> </body> </html> <?php } else { echo('You are a forum guest. Please sign in or register.'); } ?> Please help if you can. 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! I am going to use this script http://www.gayadesign.com/diy/snotify-easy-notifications-in-jquery/ but I wanted to know how exactly would I make it work like facebook does? What steps would I take to show the other user the notification rather than showing me, the sender it? Hi I am using facebook auth but email id not fetching from facebook login please help me why is happening? I'm trying to add Facebook connect to my new app, but I'm not sure where to really start. I looked through a lot of the facebook documentation, but I haven't been able to find any really good implementation suggestions. I just want basic functionality. Hey guys, Been trying to get my head around curl over the past month, I need help with loading one of Facebook's Applications. I need the script to: 1) Log into Facebook. 2) Load up the application. 3) Load up the application's iFrame. I've got steps 1 + 2 down, so it logs into Facebook and loads up the application alright, but when it comes to loading up the specific application's iframe, it re-directs me to log in again. I am 99% sure it's something to do with cookies because if you log in locally and load up the iframe url it has no problem loading up the app. (Iframe URL: http://mobsters-fb-apache-dynamic-lb.playdom.com/prod_facebook/facebook/mobsters_v1/facebook_iframe.php?track=bookmark) Here is my current code: (Running it in apache) And also I am really new to curl and am pretty much learning on the go so please excuse any obvious errors $Email = strip_tags(str_replace(' ', '', $_POST['email'])); $Password = strip_tags(str_replace(' ', '', $_POST['password'])); $MobstersURL = "http://apps.facebook.com/mobstersapp/index.php?track=bookmark&ref=bookmarks&count=0"; $FBlogin = 'https://www.facebook.com/login.php?login_attempt=1'; $Data = 'charset_test=%E2%82%AC%2C%C2%B4%2C%E2%82%AC%2C%C2%B4%2C%E6%B0%B4%2C%D0%94%2C%D0%84&lsd=vuCfh&locale=en_US&email='.urlencode($Email).'&pass='.urlencode($Password).'&default_persistent=0&charset_test=%E2%82%AC%2C%C2%B4%2C%E2%82%AC%2C%C2%B4%2C%E6%B0%B4%2C%D0%94%2C%D0%84&lsd=vuCfh'; $Cookie = "cookie.txt"; $fp = fopen($Cookie,'wb'); $agent = "Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.12) Gecko/20050915 Firefox/1.0.7"; //login to facebook $ch = curl_init(); curl_setopt($ch, CURLOPT_URL,$FBlogin); curl_setopt($ch, CURLOPT_USERAGENT, $agent); curl_setopt($ch, CURLOPT_COOKIEFILE, $Cookie); curl_setopt($ch, CURLOPT_COOKIEJAR, $Cookie); curl_setopt($ch, CURLOPT_REFERER, $FBlogin); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); curl_setopt($ch, CURLOPT_HEADER, 1); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0); curl_setopt($ch, CURLOPT_POSTFIELDS, $Data); $Excecute = curl_exec($ch); //echo $Excecute; //load up mobsters then display it curl_setopt($ch, CURLOPT_URL,$MobstersURL); curl_setopt($ch, CURLOPT_USERAGENT, $agent); curl_setopt($ch, CURLOPT_REFERER, "http://www.facebook.com/?ref=logo"); curl_setopt($ch, CURLOPT_COOKIEFILE, $Cookie); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); curl_setopt($ch, CURLOPT_HEADER, 1); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0); $LoadMobsters = curl_exec($ch); echo $LoadMobsters; //load up mobsters in iframe THIS IS WHERE I'M STUCK curl_setopt($ch, CURLOPT_URL, "http://mobsters-fb-apache-dynamic-lb.playdom.com/prod_facebook/facebook/mobsters_v1/facebook_iframe.php?track=bookmark"); curl_setopt($ch, CURLOPT_USERAGENT, $agent); curl_setopt($ch, CURLOPT_COOKIEFILE, $Cookie); curl_setopt($ch, CURLOPT_REFERER, "http://apps.facebook.com/mobstersapp/index.php?track=bookmark&ref=bookmarks&count=0"); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); curl_setopt($ch, CURLOPT_HEADER, 1); $Load_iFrame = curl_exec($ch); echo $Load_iFrame; // This is where I noticed it wasn't working since instead of loading up the iframe, it brought me back to facebook to log in. So yeah I need some help in loading up the iframe since that is where I need to grab important data. Any help would be much appreciated, and yes, I've been to http://php.net/manual/en/book.curl.php a billion times which is why I've come here where the pro's are for help Thanks. 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. 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 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> I got this piece of code:
<div class="tbl tbl-facebook" id="<? echo $site->facebook;?>"> Hey guys, i'm creating a facebook clone. Almost there, got the main/basic features all done, however i've got one piece of code which is really bugging me, don't worry about it being messy and horribley coded. I will be improving and optimising it every chance i get once i've got this down. it's on the main page, i want it to display all recent status' that have been made, i can display them however i think i've bugg'd the SQL somewhere and it's driving my crazy, any help would be greatly appriciated Thanks Code: [Select] <?php $sql = mysql_query("SELECT * FROM statuses ORDER BY id DESC"); $sql = mysql_query("SELECT * FROM statuses LEFT JOIN users ON statuses.userid = users.id"); while ($row = mysql_fetch_assoc($sql)) { $status_id = $row['id']; $status = $row['status']; $time_posted = $row['time_posted']; $sql2 = mysql_query("SELECT username,avatar_url FROM users WHERE id=$userid LIMIT 1"); while ($row2=mysql_fetch_array($sql)){ $usernamestatus = $row2['username']; $avatar_url = $row2['avatar_url']; echo '<div id="content">'; echo "<img src='/photos/$usernamestatus/$avatar_url' height='50px' width='50px' />"; echo "<a href=\"profile.php?id=$userid\">". $usernamestatus ."</a>"; echo "<br />"; echo $status; echo " <span class=x><a href=delete_status.php?id=$status_id>x</a></span>"; echo "<br />"; echo time_ago($time_posted); echo "<br />"; echo "<br />"; echo "</div>"; } } } ?> Hi, Is anyone here familiar with the Facebook API? My boss wants people to be able to share their store with their friends on Facebook from within the stores admin panel. He wants the following. 1) Display all friends with a checkbox next to each name. 2) Check the friends you want to inform about your store. 3) Post a message on checked friends wall. It sounds simple. The problem is the friends selection screen. Some of my friends on Facebook have 1000 friends. Obviously listing all of them is inpractical. Ideally I need a search box to limit the friends that display and make it easy to find who you are looking for. Does something like this already exist? Does it have a name? 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 was wondering what approach you would take to code a news feed like Facebook has. I have a status, users, and photo mysql tables. Would you create a new table called "feed" and have a query run everytime someone updates, inserts, etc anything in those three tables? or something else? What would be the most efficient way to code a news feed? Thanks in advanced! Dear all friends, I don't know this forum already have kindly of this question or not. I'm coding my won php and mysql. but I have no idea with two wanted idea as below: 1. when I post on my website. It will automaticall post in my page in facebook 2. when friend in facebook comment on that item it will also show that comment on my facebook page and also my website too. I'm please to getting your idea event from general idea and technical idea. thanks for your answer. All of your answer and idea very important to me. Best Regards Steve. 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! |