Hi today i'm going to show you how to set up facebook SDK PHP.
Everything past this line is not for people who don't know basic php / there way around a CMS so if you don't know how to code wait until people see this and release it for your CMS.
Download the SDK from github here (Only download /src)
Now create a /facebook/API/ directory and place the base_facebook.php + crt file + the facebook.php in there.
Now create a file in just /facebook/ with the name either index or facebook, whatever you want to point the URL too.
Open that up and put something in there along the lines of this (you can change this around however you want, this is just a basic login / register function)
PHP Code:
<?php
mysql_connect("localhost","root","MYSQL PASS HERE"); mysql_select_db("DB NAME HERE");
require_once("API/facebook.php"); // Change file if you have a different way of including files or want more files
define('APP_ID', 'YOUR APP ID'); // APP ID from you app page define('APP_SECRET', 'YOUR APP SECRET'); // APP Secret from your app page
$userq = mysql_query('SELECT * FROM users WHERE facebook_id = "'.$profile['id'].'"') or die(mysql_error()); $users = mysql_fetch_array($userq); $num = mysql_num_rows($userq);
$fbname = "NewUser";
if($num > 0){
// Login function here or starting session // header("location:/redirect");
} else {
// Login & Register a user here and redirect to wherever // header("location:/redirect");
}
?>
Here's the HTML code for the button, also change these settings (most are labelled).
PS - This is if you're using habbos css/js so i dunno if your not..
Almost forgot, you need your own facebook app, so i'l show you how!
Click here to show your current apps and the create an app button.
Click the "Create new app" button to start.
Now just type in your basic info..
Spoiler:
Now your going to need to edit the Site URL, to your facebook index/login url. (/facebook/index.php or /facebook/facebook.php)
Spoiler:
Covered app secret + email.
Now just copy your APP ID + APP SECRET and put it in the files that require editing (not anything in /api).
The outcome
Spoiler:
A working facebook login!
Note : Like + Rep to show respect to the creator of the tut
PS, you need cURL enabled for this to work. If you code PHP you can have a nice choose name function / choose pass aswell. For now the $username variable generates random usernames like User1256 and then they can change there username in-client if your using R63B otherwise code a if($_POST['form'] etc.
Last edited by JaydenC; 02-03-13 at 11:35 PM.
Reason: Extra Information
Right sir, this is very good and tidy.
I also found that when you change your username in-client, you cant login anymore x]
Gonna test this out, and work on it for Uber CMS x] (Me no like Rev)
Not sure, i'l do a basic web-based change username script if needed?
Make sure you look over the main php, cause you need to add your own register/login functions like
$users->adduser(Jayden,Motto,Look); etc - this wont work btw
Not sure, i'l do a basic web-based change username script if needed?
Make sure you look over the main php, cause you need to add your own register/login functions like
$users->adduser(Jayden,Motto,Look); etc - this wont work btw
Yeah, casn you make a web based change username script then? I have some sort of example in my mind on how to do it, but meh.
Im looking over the main php and trying to figure it all out, i only know a small amount of php, but just learning x]
For the username creation thingy you can use $fbdata['username'] to make it more like them. Plus you should never trust users input, not even facebooks API :p
For the username creation thingy you can use $fbdata['username'] to make it more like them. Plus you should never trust users input, not even facebooks API :p
And you think FACECBOOK wouldn't have a some sort of incredible impossible to beat username safety script? the thing you should be worried about is admin-etc.
PS : I don't think you can take username/real name anymore because they have a security thing. You can however get there "aboutme" + email i believe. Its all here.