PHP - Facebook Api - Opengraph After Login
hey all
i have a facebook connect script which is working fine, and after the user logs in, it returns your facebook data (name, id etc)
attached to this post is the script - which works great if anyone is looking for a good example
Once the user has logged in, I want to run on a seperate page, a script which pulls data about a specific pages
My question is, how much of the attached code can be removed once the user has logged in, i'd asume as the user is already logged in, there is a bunch of code which deals with the login processs which could be deleted
or do i have to use the whole script when accessing anything on the graph?
Similar TutorialsHi there. Having a little trouble getting Open Graph working with my facebook like button. I can put text in fine but I want the following variables to be represented in the head information so that I can edit the head data periodically. Would appreciate any help. I've tried "<?php echo $blahblah ?>" which doesn't seem to work. Confirmed that nothing was being pulled by Facebook's linter... Code: [Select] //Variable for Head. $id = '1'; $promo_id = $id; //Change this to be variable with function... $promo_title = "Goody Bag"; $promo_text = cms::string('copy.goody_bag.sub_title'); $promo_image = "/assets/images/goody_bag/goody_bag_small_bg.png";//Change this to be variable with function... $promo_description = cms::string('copy.goody_bag.text'); //These are to be put into the head information but will need to be made variable using either the controller or the iframe.php ?> <html xmlns="http://www.w3.org/1999/xhtml" xmlns:og="http://opengraphprotocol.org/schema/" xmlns:fb="http://www.facebook.com/2008/fbml"> <head> <title></title> <meta property="og:title" content="Goody Bag"/> <meta property="og:type" content="website"/> <meta property="og:url" content="http://apps.facebook.com/ztoa_dev/like/show_like/1"/> <meta property="og:image" content="http://apps.facebook.com/ztoa_dev/assets/images/goody_bag/goody_bag_small_bg.png?2"/> <meta property="og:site_name" content="Z to A by Sunsilk"/> <meta property="fb:admins" content=""/> <meta property="og:description" content="Blah Blah Blah"/> </head> Hello guys, Is there on web any updated tutorial on how can I add Facebook login on my simple php login script? Hi, I am planning to integrate Facebook login into my site, I found this useful guide: Code: [Select] http://www.1stwebdesigner.com/tutorials/facebook-integrate/ Has anyone tried it before, if so how difficult would you say it is to do this? My site is operated by matching id numbers with username. How would I get a username from a Facebook login? This topic has been moved to Third Party PHP Scripts. http://www.phpfreaks.com/forums/index.php?topic=357535.0 Hi i have a facebook login social plugin made but my ? is why do i get symbols in my url link ?. I login with the plugin to facebook but when page returns me back to my site i have symbols at the end of url. Like this http://www.games-flash.co.uk/#_=_ Ps sry if i have made this post in wrong section. I need some guidance in regards to adding Login with Facebook.
Is this something which is easily done? Currently, I'm using UserCake:
http://usercake.com/
How much testing and QA is necessary for this type of work?
http://pixpresso.mycyberlove.com/ This is my test hosting for this site I'm making. Navigation and facebook login are almost done. So, the problem is that after facebook login URL is http://pixpresso.mycyberlove.com/#_=_ Why is this? Is this bad, should I and can I remove this? I created an app for my website, set action (read) and object (article), and placed the objects code (META tags in the head) at the article page on my website. Now, I want to know how to send a cUrl request whenever a user reads an article on my website, so it'll feature on his wall. When I press the "get code" link near the action, that's what I get: Code: [Select] curl -F 'access_token=***' \ -F 'article=http://example.com' \ 'https://graph.facebook.com/me/yellowheart:read' (There's an actual access token of course). Now, how do I make it happen? Daniel hi i need help an idea how can i separate members from admins since i dont know how to create login form i used tutorial ( http://www.youtube.com/watch?v=4oSCuEtxRK8 ) (its session login form only that i made it work other tutorials wre too old or something) how what i want to do is separate members and admins because admin need more rights to do now i have idea but dont know will it work like that what i want to do is create additional row in table named it flag and create 0 (inactive user) 1 (member) 2 (admin) will that work? and how can i create different navigation bars for users and admins? do you recommend that i use different folders to create it or just script based on session and flag? Hi guys. What I want to create is really complicated. Well I have a login system that works with post on an external website. I have my own website, but they do not give me access to the database for security reasons, therefore I have to use their login system to verify my users. What their website does is that it has a post, with username and password. The POST website is lets say "https://www.example.com/login". If login is achieved (i.e. username and password are correct), it will redirect me to "https://www.example.com/login/success" else it will redirect me to "https://www.example.com/login/retry". So I want a PHP script that will do that post, and then according to the redirected website address it will return me TRUE for success, FALSE for not successful login. Any idea?? Thanks How to add the ability to login with username or email for login?
<?php ob_start(); include('../header.php'); include_once("../db_connect.php"); session_start(); if(isset($_SESSION['user_id'])!="") { header("Location: ../dashboard"); } if (isset($_POST['login'])) { $email = mysqli_real_escape_string($conn, $_POST['email']); $password = mysqli_real_escape_string($conn, $_POST['password']); $result = mysqli_query($conn, "SELECT * FROM users WHERE email = '" . $email. "' and pass = '" . md5($password). "'"); if ($row = mysqli_fetch_array($result)) { $_SESSION['user_id'] = $row['uid']; $_SESSION['user_name'] = $row['user']; $_SESSION['user_email'] = $row['email']; header("Location: ../dashboard"); } else { $error_message = "Incorrect Email or Password!!!"; } } ?>
Hi guys, Can anyone assist me. I am trying to create a login for admin and user (if user not a member click register link) below is my code: But whenever I enter the value as: Username: admin Password:123 - I got an error message "That user does not exist!" Any suggestion and help would be appreciated. Thanks. login.php <?php //Assigned varibale $error_msg as empty //$error_msg = ""; session_start(); $error_msg = ""; if (isset($_POST['submit'])) { if ($a_username = "admin" && $a_password = "123") { //Define $_POST from form text feilds $username = $_POST['username']; $password = $_POST['password']; //Add some stripslashes $username = stripslashes($username); $password = stripslashes($password); //Check if usernmae and password is good, if it is it will start session if ($username == $a_username && $password == $a_password) { session_start(); $_SESSION['session_logged'] = 'true'; $_SESSION['session_username'] = $username; //Redirect to admin page header("Location: admin_area.php"); } } $username = (isset($_POST['username'])) ? $_POST['username'] : ''; $password = (isset($_POST['password'])) ? $_POST['password'] : ''; if($username && $password) { $connect = mysql_connect("localhost", "root", "") or die ("Couldn't connect!"); mysql_select_db("friendsdb") or die ("Couldn't find the DB"); $query = mysql_query ("SELECT * FROM `user` WHERE username = '$username'"); $numrows = mysql_num_rows($query); if ($numrows != 0){ while ($row = mysql_fetch_array($query)) { $dbusername = $row['username']; $dbpassword = $row['password']; } //Check to see if they are match! if ($username == $dbusername && md5($password) == $dbpassword) { header ("Location: user_area.php"); $_SESSION['username'] = $username; } else $error_msg = "Incorrect password!"; //code of login }else $error_msg = "That user does not exist!"; //echo $numrows; } else $error_msg = "Please enter a username and password!"; } ?> <!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=iso-8859-1" /> <title>Login Page</title> </head> <body> <br /> <?php require "header.php"; ?><br /> <div align="center"> <table width="200" border="1"> <?php // If $error_msg not equal to emtpy then display error message if($error_msg!="") echo "<div id=\"error_message\"style=\"color:red; \">$error_msg</div><br />";?> <form action="<?php echo $_SERVER['PHP_SELF'];?>" method="post"> <!--form action="login_a.php" method="post"--> Username: <input type="text" name="username" /><br /><br /> Password: <input type="password" name="password" /><br /><br /> <input type="submit" name = "submit" value="Log in" /> </form> <p> </p> Register a <a href="register.php">New User</a> </table> </div> </body> </html> 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. 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. 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'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. 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, 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 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 |